Add a flash READNUM command for reading numeric variables
Posted: Sat May 14, 2016 4:23 pm
READ and WRITE to flash memory is great for string variables, but can be much more problematic for numeric variables.
If you WRITE a numeric variable called Duration with a value of 5000, you can't then READ it back into Duration without Duration now becoming a text variable which will most likely cause operational errors if manipulated or compared.
READ reads the flash text variable directly into the specified variable name, so you can't do a val() of the text to convert it during the READ. The only way of NOT converting your previous numeric variable into a text variable is to NOT READ back into it, and do something like...
READ FlashVarName temp
let Duration = val(temp)
It works, but it's not nice when you have several saved numbers to READ back, and it's something that might be improved upon when time permits.
It could easily be catered for by an additional READNUM command that internally did a val(string) of the required read numeric variable.
It could also benefit from some accompanying housekeeping commands that would allow listing, renaming, and deleting of flash variables - because currently the only way is to reformat and reflash the ESP.
If you WRITE a numeric variable called Duration with a value of 5000, you can't then READ it back into Duration without Duration now becoming a text variable which will most likely cause operational errors if manipulated or compared.
READ reads the flash text variable directly into the specified variable name, so you can't do a val() of the text to convert it during the READ. The only way of NOT converting your previous numeric variable into a text variable is to NOT READ back into it, and do something like...
READ FlashVarName temp
let Duration = val(temp)
It works, but it's not nice when you have several saved numbers to READ back, and it's something that might be improved upon when time permits.
It could easily be catered for by an additional READNUM command that internally did a val(string) of the required read numeric variable.
It could also benefit from some accompanying housekeeping commands that would allow listing, renaming, and deleting of flash variables - because currently the only way is to reformat and reflash the ESP.