PureBasic 5.20 beta 20 is out

Developed or developing a new product in PureBasic? Tell the world about it.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: PureBasic 5.20 beta 4 is ready to test !

Post by davido »

@Fred
Just downloaded it. Looks fine. :D

Thank you for all the hard work.
DE AA EB
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: PureBasic 5.20 beta 4 is ready to test !

Post by DoubleDutch »

Thanks
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Re: PureBasic 5.20 beta 4 is ready to test !

Post by Rescator »

Awesome! A large project I'm working on here compiles fine with debugger both on and off with Beta4.
Only had to do two minor edits (two constant name changes).

Go Fred! :)
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: PureBasic 5.20 beta 4 is ready to test !

Post by luis »

Thanks.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: PureBasic 5.20 beta 4 is ready to test !

Post by Psychophanta »

:D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: PureBasic 5.20 beta 1 is ready to test !

Post by charvista »

Kwaï chang caïne wrote:

Code: Select all

Added: Gosub are now allowed again inside Procedure
An old request....thanks a lot FRED 8)
KCC saw somewhere that Gosub is now allowed inside Procedure (I don't see it however).
With the beta 3 I still cannot.
I need to know if the Gosub within procedures will come, yes or no.
If Yes, I will wait for the definitive launching of 5.20.
If No, when then, Ever or Never?
This to avoid a mess in my programming, Gosub would be REALLY great.
Thanks for confirming.
Cheers
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PureBasic 5.20 beta 4 is ready to test !

Post by skywalk »

Fred wrote:update: beta 2 is available and with the usual bug fixes. As well, zlib have been updated to 1.2.8 and Gosub in procedure have been removed as it can't work for now.
Gosub Bug...
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: PureBasic 5.20 beta 4 is ready to test !

Post by charvista »

OK, thanks Skywalk. Maybe for v5.30 then :cry:
Danilo wrote last year in april an assembler routine that seemed to work, but I have issues with variables now. Here is Danilo's version again:

Code: Select all

;*====================*===========================================================================================================*
;| Macro .............| mSub
;| Description .......| Gosub in procedures
;| Syntax ............| mSub
;| Parameter(s) ......|
;| Author(s) .........| Danilo
;| Version(s) ........| 2012-04-24
;*--------------------*-----------------------------------------------------------------------------------------------------------*
;| Remarks ...........|
;| Usage example .....|
;*====================*===========================================================================================================*

; The following initializations are required; they are in #Constants.pbi
;******************************************************************************************
; #SUB_STACKSIZE = 100000; number of possible nested subs 
; Global __Sub_ReturnAddress__.s{(#SUB_STACKSIZE+1)*(SizeOf(Integer)/SizeOf(character))}
; Global __Sub_ReturnIndex.i
;******************************************************************************************

;=================================================================================================================================*
Macro mSub(_name_)
    CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 Or #PB_Compiler_Processor = #PB_Processor_x64
        !EndSub_Name equ __EndSub_#_name_
        !  JMP EndSub_Name
        !_sub_#_name_:
    CompilerElse
        CompilerError "Macro Sub(): unsupported processor"
    CompilerEndIf
EndMacro
;=================================================================================================================================*
Macro mExitSub
    CompilerSelect #PB_Compiler_Processor
        CompilerCase #PB_Processor_x86
            !  MOV dword EAX, v___Sub_ReturnAddress__
            !  MOV dword EDX, [v___Sub_ReturnIndex]
            !  JMP dword [EAX+EDX*4]
        CompilerCase #PB_Processor_x64
            !  MOV RAX, v___Sub_ReturnAddress__
            !  MOV R8, [v___Sub_ReturnIndex]
            !  JMP qword [RAX+R8*8]
        CompilerDefault
            CompilerError "Macro ExitSub: unsupported processor"
    CompilerEndSelect
EndMacro
;=================================================================================================================================*
Macro mEndSub
    mExitSub
    !EndSub_Name:
EndMacro

; Macro mEndSub
;     CompilerSelect #PB_Compiler_Processor
;         CompilerCase #PB_Processor_x86
;             !  MOV dword EAX, v___Sub_ReturnAddress__
;             !  MOV dword EDX, [v___Sub_ReturnIndex]
;             !  JMP dword [EAX+EDX*4]
;             !EndSub_Name:
;         CompilerCase #PB_Processor_x64
;             !  MOV RAX, v___Sub_ReturnAddress__
;             !  MOV R8, [v___Sub_ReturnIndex]
;             !  JMP qword [RAX+R8*8]
;             !EndSub_Name:
;         CompilerDefault
;             CompilerError "Macro EndSub: unsupported processor"
;     CompilerEndSelect
; EndMacro
;=================================================================================================================================*
Macro mCall(_name_)
    CompilerSelect #PB_Compiler_Processor
        CompilerCase #PB_Processor_x86
            !  INC dword [v___Sub_ReturnIndex]
            !  MOV dword EAX, v___Sub_ReturnAddress__
            !  MOV dword EDX, [v___Sub_ReturnIndex]
            !  MOV dword [EAX+EDX*4], @f
            !  JMP _sub_#_name_
            !@@:
            !  DEC dword [v___Sub_ReturnIndex]
        CompilerCase #PB_Processor_x64
            !  INC qword [v___Sub_ReturnIndex]
            !  MOV R9, @f
            !  MOV RAX, v___Sub_ReturnAddress__
            !  MOV R8, [v___Sub_ReturnIndex]
            !  MOV qword [RAX+R8*8],R9
            !  JMP _sub_#_name_
            !@@:
            !  DEC qword [v___Sub_ReturnIndex]
        CompilerDefault
            CompilerError "Macro Call(): unsupported processor"
    CompilerEndSelect
EndMacro
;=================================================================================================================================*
And today I am trying using Goto's... (spaghetti-code!) while awaiting for the real Gosub inside procedures...

Code: Select all

; Procedure a()
;     v.i=5
;     Gosub aa
;     Debug v
;     ProcedureReturn
;     
;     aa:
;     v+8
;     Return
;     
; EndProcedure



Procedure b()
    v.i=5
    
    Locate=1 : Goto bb
    bb1:
    Debug v
    ProcedureReturn
    
    bb:
    v+8
    If Locate=1 : Goto bb1 : EndIf
    
EndProcedure



;a()
b()
skywalk wrote:"that Fred has written:

it can't work for now.
So hopefully it will come any day.
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: PureBasic 5.20 beta 1 is ready to test !

Post by RichAlgeni »

charvista wrote:I need to know if the Gosub within procedures will come, yes or no.
If Yes, I will wait for the definitive launching of 5.20.
If No, when then, Ever or Never?
This to avoid a mess in my programming, Gosub would be REALLY great.
Thanks for confirming.Cheers
You have over 700 posts, so I will not presume that you are a newbie when it comes to coding, but is this something you can do with a procedure? I'd be glad to try and help you, as would many on the forums. I was a big proponent of using Gosubs, but because of the power of procedures, I never use them anymore.
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: PureBasic 5.20 beta 4 is ready to test !

Post by charvista »

RichAlgeni wrote:is this something you can do with a procedure?
Sure, it can. The only (and big) difference, is that we need to bring all the necessary variables through the argument parameters. Plus, that there is no ByRef possibility (only ByVal), so there is no way to give back the modified variables to the caller -- except with an array, but that is not convenient. And yes, pointers are also possible, and I am using them when absolutely necessary, for integers it is easy, but when you have strings, hello complications... especially when this pointer is calling a second procedure level! If we modify the program later, we need to update the procedure's arguments, plus the Declare as well!
A Gosub is very simple and all variables are available.
Yes, procedures are powerful, but their concept is different.

I just remember that even Goto has problems: it may not be used within a Select block, otherwise variables will lose their values, and the program *can* hang. So probably the same for Gosub, because it is in fact internally nothing more than two Gotos.
RichAlgeni wrote:I'd be glad to try and help you
Thank you RichAlgeni. I am also happy when I can help someone :)
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: PureBasic 5.20 beta 4 is ready to test !

Post by RichAlgeni »

charvista wrote:And yes, pointers are also possible, and I am using them when absolutely necessary, for integers it is easy, but when you have strings, hello complications...
You are right, pointers are complicated to use, but once you get used to them, pointers can be WONDERFUL! I do use Global strings, but mostly just as parameters. I never pass strings to a procedure, it it doubles the memory use for the string, and like you know, you don't get modifications back.

You do have to account for the string size, but I pass that do when needed. You can pass integers as a pointer, but you are only required to do so when you need to modify the integer.

I try to create small, process independent procedures, that way I can 'include' them into new programs.

Everyone has their own style and way of doing things. No one way is best, but I've found that avoiding Gosub's and especially Goto's are the best way for me to code. I also teach that way, and find that once students get used to no gosub's and goto's, they don't really miss them.

Rich
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: PureBasic 5.20 beta 4 is ready to test !

Post by charvista »

RichAlgeni wrote: pointers can be WONDERFUL!
I agree!
I am using global variables only as a type of constants that can be changed later. I recognize my constant variables by prefixing an underscore to the variable, ex: _DW.
It looks like you are a school teacher. Are you teaching PureBasic? Interesting.
I have written a little program that helps me how the variables need to be used when they are passed as pointer, because I cannot remember them easily.
First time, you use @var, then use *var\s, but when passing to a second level proc, use *var. That's why I prefer the "basic" var.s !

If pointers are so fast, I wonder why the standard variables are not pointers internally... but I am sure there is a good reason!

I am using Goto often, but rarely. Do you get it? :wink:

Code: Select all

; this is how to use ByRef with string variables

Procedure shower(cont.s) ; here using standard variable, so no change at exit
    cont.s+" Africa." : Debug cont.s
EndProcedure


Procedure addmore(*v.string)
    *v\s+" Asia." : Debug *v\s
EndProcedure


Procedure change(*v.string)
    *v\s+" America." : Debug *v\s
    addmore(*v)      : Debug *v\s
    shower(*v\s)     : Debug *v\s
EndProcedure




;start =================================================================
Define.string tvar, alpha ; or Define tvar.string

tvar\s="Europe." : Debug tvar\s
change(@tvar)    : Debug tvar\s
Debug tvar; this will show the pointer number!




Debug "================================================================"
; and this is how to use ByRef with integer variables (same rule applies to double, long, quad)

Procedure intshow(ival.i)
    ival.i+14 : Debug ival
EndProcedure

Procedure intchangemore(*i.integer)
    *i\i+27 : Debug *i\i
EndProcedure

Procedure intchange(*i.integer)
    *i\i+15           : Debug *i\i
    intchangemore(*i) : Debug *i\i
    intshow(*i\i)     : Debug *i\i
EndProcedure

;start =================================================================
i.i=17        : Debug i.i
intchange(@i) : Debug i.i
Debug i; this, in contrast to strings, it shows the real value! (only for integers)
Please let me know if this is the good way. And of course, you can use it as a reference for your students.
Cheers
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 5.20 beta 4 is ready to test !

Post by Fred »

Please use a different thread for such questions, it's annoying, thanks.
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: PureBasic 5.20 beta 5 is ready to test !

Post by RichAlgeni »

Fred is exactly right, my fault!

@Charvista, create a post in coding questions, that way more will feel free to contribute.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureBasic 5.20 beta 5 is ready to test !

Post by c4s »

I like how fast you guys are. Thanks for releasing another beta! :o
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply