Problems with gosub
grunge
Posts: 5
Hello, i·want to know how can i use GOSUB in other "unit/project"...
i wanna do something like this (exemple):
'
[noparse][[/noparse]THIS IS UNTITLED1]
' {$STAMP BS2sx, Untitled2.bsx}
' {$PBASIC 2.5}
GOSUB a1
'
[noparse][[/noparse]THIS IS UNTITLED2]
' {$STAMP BS2sx}
' {$PBASIC 2.5}
a1:
DEBUG "xalala"
and i want to know if i can do it with variables like con's and pin's...?
I hope I explained it clearly.
grateful for the attention
i wanna do something like this (exemple):
'
[noparse][[/noparse]THIS IS UNTITLED1]
' {$STAMP BS2sx, Untitled2.bsx}
' {$PBASIC 2.5}
GOSUB a1
'
[noparse][[/noparse]THIS IS UNTITLED2]
' {$STAMP BS2sx}
' {$PBASIC 2.5}
a1:
DEBUG "xalala"
and i want to know if i can do it with variables like con's and pin's...?
I hope I explained it clearly.
grateful for the attention
Comments
You have probably read some about "multi-slot" programs each of which reside in a 2K "slot" in the Stamps with 16K of program memory like the BS2sx. There are no subroutine calls between slots. It is possible to make the slot programs behave somewhat like subroutines, but it takes some work on your part and the GOSUB can't be used. When a program in a new slot is started, it begins at its beginning and there's no memory of where it came from (unless you keep track of that yourself in the programs). There's a document on multi-slot programming that discusses this (Nuts and Volts Column #87 ... Choose the Resources tab from the main Parallax webpage for a link to the index).
and if i understand it correctly, this happens only with BS2e, BS2sx, BS2p, right?
but...if i use BS2PE, i can do what i want or no too?
http://forums.parallax.com/showthread.php?p=741023
because now as I can't download your code, but later I'm gonna see ... thanks for the tip