Global Variables????
NerdicusMaximus
Posts: 11
I am trying to use the polling function to change a variable in my code.
It is my understanding that pollout can put a pin high and pollrun can send you to another file in a multi-file program.
I have tried the pollrun option, but it doesn't bring over my variables for manipulation....
So I tried writing my variable to a place in memory first (Write 1, global) then pollrun to another file, create the same variable in the new file, call it from memory (Read 1, global), manipulate it (global=global + 1) then write it back to the same place (Write 1, global)....
When I return to the original "main" file of my program, it turns out that the address 1 is different for each file in the multi-file program.
Is there a way to call the absolute memory address 1 instead of the relative file memory address?
Maybe there is a way to have pollrun or some other version of polling send me to a different section of my program using a GOTO statement?
Or even better is there a way to make a global variable across the files?
I would appreciate some help here.
B
It is my understanding that pollout can put a pin high and pollrun can send you to another file in a multi-file program.
I have tried the pollrun option, but it doesn't bring over my variables for manipulation....
So I tried writing my variable to a place in memory first (Write 1, global) then pollrun to another file, create the same variable in the new file, call it from memory (Read 1, global), manipulate it (global=global + 1) then write it back to the same place (Write 1, global)....
When I return to the original "main" file of my program, it turns out that the address 1 is different for each file in the multi-file program.
Is there a way to call the absolute memory address 1 instead of the relative file memory address?
Maybe there is a way to have pollrun or some other version of polling send me to a different section of my program using a GOTO statement?
Or even better is there a way to make a global variable across the files?
I would appreciate some help here.
B
Comments
From the help file :- "Designate a program slot for the READ and WRITE instructions to operate upon"
hope this helps
Jeff T.
Moreover, normal variables like x in the above program carry over unchanged from slot to slot. More corrrectly stated, the physical locations in the 26 bytes of RAM memory carry over, and the variable names in the two slots can be named in the same order in both slots so that they do in fact refer to the same physical locations.
And again, there is scratchpad RAM in the multibank Stamps, and that carries over globally from slot to slot. So in the above snippet, you could replace WRITE with PUT and READ with GET, and leave out the STORE.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support