Comparing a variable with a value in eeprom using read and write

ac246

New Member
Hey
Wondering if anyone can help,
Im saving some values into EEPROM for example write 0,b6. So writing the value of b6 into location 0. B6 can then change,I'm using EEPROM so I don't lose the value when the circuit is turned off. But then I want to compare the value of EEPROM location 0 with b6 later on so I am reading the original value back into b14, using read 0,b14. Then comparing the new b6 with the original value of b6 which is now in b14. Im wondering if I can directly compare a variable with an EEPROM value without having to read it into a variable. The part of code/pseudo is as follows,*

B6 receives a value
Write 0,b6 'store b6 in location 0

Period of time*

B6 recieves another value
Read 0,b14 'read location 0 into b14

If b6 = b14 then 'compare the original value with the new value
'Code here
End if.*

I'm wondering now. Can I do something like if b6 = EEPROM location 0 then....

I'm trying to free up some variables which is why I'm looking for a more direct way, cheers.
 

hippy

Ex-Staff (retired)
No, you can only do it as you are doing, read into a variable, compare with another variable.
 

ac246

New Member
ah ok. shame.. thanks anyway.
and is there a way of making a sentance continue onto a new line like below.. im trying to put boxes round things and when i print it messes things up.. in VBA i think i used to be able to put an underscore at end of the line and continue on the line below.

thanks

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if b6 = b14 and b7 = b15 and b8 = b16 and b9 = b17 and b10 = b18 _ '
and b11 = b19 and b12 = b20 and b13 = b21 then ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
Last edited:

westaust55

Moderator
Running out of variable:
If you are only using the variable b14 to under take the mentioned test, then at other times you can reuse b14 for some other temporary purpose.
Alternatively you can save the variables to the scratchpad area (if the PICAXE you are using has scratchpad memory) or to un designated RAM locations as described in the Variables section of PICAXE manual 2. See under the heading “Variables – Storage” on page 11 in the manual 2 (V7.2 )
 
Top