multiple programs
electromanj
Posts: 270
Hello, I have a question about running multiple programs on a bs2SX. Do variables transfer from one program to another? Do I need to declare the variable in every new program?
Example:
Program 0
' {$STAMP BS2sx,program1.bsx}
' {$PBASIC 2.5}
LED var byte
DEBUG· "Please enter·LED 1-4 ---> "
DEBUGIN DEC1 LED
RUN 1
Program 1
' {$STAMP BS2sx}
' {$PBASIC 2.5}
LED var byte
if LED=1 then high 1
if·LED=2 then high 2
if LED=3 then high 3
if LED=4 then high 4
·
Example:
Program 0
' {$STAMP BS2sx,program1.bsx}
' {$PBASIC 2.5}
LED var byte
DEBUG· "Please enter·LED 1-4 ---> "
DEBUGIN DEC1 LED
RUN 1
Program 1
' {$STAMP BS2sx}
' {$PBASIC 2.5}
LED var byte
if LED=1 then high 1
if·LED=2 then high 2
if LED=3 then high 3
if LED=4 then high 4
·
Comments
I'd say you probably want to read that part of the help file carefully. It looks like not only do you have to redeclare the variables, you have to be very careful about how you do so.
I will read that help file. I also came across a similar post about more EEPROM a little further down the page, with a reference to Nuts and Volts article #87. (Thank you Mike Green). I am reading that also.
Upon further reading of the help file it appears that you can transfer var between programs as long as you define them in the right order.
If you defined them all as words in the same order they would transfer correctly. Is this right?
Yes that is correct, you can use the same variables across the slots. Here is a little sample that puts a value in a var and then goes to another slot to display it. Hope this helps
I used the BS2sx, but you could do the same with any of the multi-slot BASIC Stamp 2 modules. If you open temp0.bsx it will open temp1.bsx automatically.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
I have one more question on this subject.
If you have more than one variable, does it matter what order you put the variables in the different slots?
Example:
Program 0
LED var word
SETPOINT var word
Program 1
SETPOINT var word
LED var word
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 1/20/2010 4:32:24 AM GMT
Thanks to everyone for all the help!!!!!!!!!!!!!!
P.S. Thanks for keeping the explanations simple. They were really easy to understand.