Prototype proto_none() ; Declare your Procedure with Parameters
Structure struct_callprocs ; set it into a structure
Go.proto_none
EndStructure
; your procedures
Procedure DrawValue1()
Debug "Value = 1"
EndProcedure
Procedure DrawValue2()
Debug "Value = 2"
EndProcedure
Procedure DrawValue3()
Debug "Value = 3"
EndProcedure
; Declare an array
Global Dim DrawValues.struct_callprocs(3)
; Set the adresses of the procedures to the array
DrawValues(1)\Go = @DrawValue1()
DrawValues(2)\Go = @DrawValue2()
DrawValues(3)\Go = @DrawValue3()
; Let the show begin ....
Value = 1
If Value > 0 And Value <= ArraySize(DrawValues())
DrawValues(Value)\Go()
Else
Debug "Don't know"
EndIf
Thanx to Stargate, who shows me this way years ago.
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom
English is not my native language... (I often use DeepL to translate my texts.)
Rewrite your code to use procedures and macros instead of goto/gosub. There is nothing that you can not do with procedures and macros but can with goto/gosub. I can not think of any goto/gosub advantage. Ok, maybe code readability in some cases. But you can always name your procedure or macro gosub_DrawValue() in these rare cases.
Hi Bisonte,
thanks for your help,
I rewrote my program with goto's in place of gosub's
and all works well,
so, it seems you are right it seems to be a problem with gosub return address. (? stack)
Hi cas,
well I'm programming for a long time this way,
and never had problems till this morning.
I must say that I just upgraded PB to PB 5.45F LTS x64 and 5.61F x64
to all,
- is there someone who knows how deep the gosub nesting may be in PB (levels)
- how big is the stack used by PB ?
- and can I set this stack memory size myself ?
tanks,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...