Dynamic variables with LONGMOVE?
eagletalontim
Posts: 1,399
Is there a way to use LONGMOVE to copy data from one variable to another where the receiving variable name changes?
Example :
I have not tested the code above. Doing this off the top of my head....
Example :
DAT Start_User_Settings User_Setting1 LONG 1 User_Setting2 LONG 456 User_Setting3 LONG 15040 End_User_Settings OBJ eeprom : "Propeller_Eeprom" PUB main | current_value current_value := 555 copy_me(current_value, 2) PUB copy_me(the_value, setting_number) size := strsize(the_value) LONGMOVE(@User_Setting + "0" + setting_number, @the_value, size)
I have not tested the code above. Doing this off the top of my head....
Comments
The "0" seems out of the blue. You'd normally only use the '+ "0"' trick on a single character to change it from its numeric value to an ASCII value/character.
What do you mean by "host" variable name change? Oh, I see (sort of what you're trying to do. No, You can't manipulate variable names. You can treat other variables as an element of an array named by an earlier (or even later variable).
For example. "User_Setting2" is the same as "User_Setting1[1]".
The variable names are not compiled as names. Your compiled code shown by F8 will be the same no mater what you call your variables.