Shop OBEX P1 Docs P2 Docs Learn Events
global variable — Parallax Forums

global variable

ionion Posts: 101
edited 2006-05-18 22:16 in BASIC Stamp
Hi
How i can set a variable on program 0 on a bs2e and have the same value used in program 1 ?
On bs2p it is easy, because you use STORE comand, which does not exist on BS2E.
The program is longer then one 2K page so i divided in 3 sections. On section one i calculate some variable, which i need to use in the other twp sections. I can not take the portion of the program and recalculate them again in section two or three ( read program page 1 and 2) because i do not have room.
Please help
Thank you
Ion
·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-18 02:43
    Actually the STORE command has nothing to do with variables.· That only affects data written to the EEPROM.· If you declare your variables the same in all slots, they will be preserved.· Make sure you copy and paste the variable declarations so you're sure they're all the same.· No more, no less.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ionion Posts: 101
    edited 2006-05-18 03:50
    Thank you Chris
    In reality, what i did it was to write and read some data on one of the slots. but of course, reading made it a variable so now i know what to do.
    Thank you
    Ion
  • NewzedNewzed Posts: 2,503
    edited 2006-05-18 11:52
    To emphasize what Chris said, the variables in each slot must be exactly the same and EXACTLY in the same order.· The Stamp reads variables by position, not by name.· If a is the first variable in slot 0 and b is the first value in slot 1, then if you call b from slot 1, you will get the value of a from slot 0.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-18 14:13
    ion said...(trimmed)
    In reality, what i did it was to write and read some data on one of the slots. but of course, reading made it a variable so now i know what to do.
    Bear in mind that doing this frequently will wear out the EEPROM locations you are using.· The EEPROM has a finite write lifetime and if you're using it like variable storage then you will very quickly wear it out and those locations will not be writeable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ionion Posts: 101
    edited 2006-05-18 22:09
    Thnak you for support and advice, but i am still in the dark. Let explain: in the first part of the program i·calculate some data which i write it on the memory location from 0 to 30. The address where is writen is calculated based in other parameters. In the second part of the program ( which is long and does not fit in one slot) i have to read back the values. Of course i use one variable and i calculate the address. With P version of chips, was simple because i used STORE, but for 2E i do not have this luxury. What i need is a way to read all the values from slot 0 from adress 0 to 30 and write them back on slot 1 before i start the rest of the program. In this case , every time when i use that variable, i just give the adress and have it.

    Thanks

    Ion
  • NewzedNewzed Posts: 2,503
    edited 2006-05-18 22:16
    When you write something to EEPROM from slot 0, that data can not be read by any other slot.· Each slot has its own EEPROM not accessible by other slots.· To to what you want to do you would have to write to EEPROM in slot 0 then repeat the write in slot 1.· You can pass variables from slot to slot but not EEPROM data.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
Sign In or Register to comment.