Just downloaded it. Looks fine.

Thank you for all the hard work.
KCC saw somewhere that Gosub is now allowed inside Procedure (I don't see it however).Kwaï chang caïne wrote:An old request....thanks a lot FREDCode: Select all
Added: Gosub are now allowed again inside Procedure
Gosub Bug...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.
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
;=================================================================================================================================*
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()
So hopefully it will come any day.skywalk wrote:"that Fred has written:
it can't work for now.
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.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
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!RichAlgeni wrote:is this something you can do with a procedure?
Thank you RichAlgeni. I am also happy when I can help someoneRichAlgeni wrote:I'd be glad to try and help you
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.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...
I agree!RichAlgeni wrote: pointers can be WONDERFUL!
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)