Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:04 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : var save

Author Message
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 10:45pm 21 Feb 2015
Copy link to clipboard 
Print this post

With Var Save the manual says you can have any number of numeric or string variables but really you are limited by the line length of the editor.

If you striped down and used
var save a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac ,ad,ae,af
you can save only 32 variables (yes you can have more but they will be off screen.)
If you used your actual variable names then the 'max' number will be a lot less.

Should there/is there be a way to list the variables on multiple lines?

[MMBasic 4.6B]


Edit Add:

Perhaps the following might be a way.

VAR Save alfa,bravo,charlie,delta,echo,foxtrot,golf,hotel,india,juli ett,kilo,lima 'whoops too long and only 12 variables

so instead
------------
VAR Save alfa,bravo,charlie,delta,echo 'save these
VAR Save foxtrot,golf,hotel,india 'and save these
VAR Save juliett,kilo,lima,mike 'and these
VAR Save november,oscar,papa,quebec 'and so on.
-------------
VAR Save 'clear all and
VAR Save foxtrot,golf,hotel 'save these - this mimics current behaviour
--------------
VAR Restore 'restore all saved variables
VAR Restore alfa,hotel,mike,papa 'restore selected variables which makes it a lot clearer as to what you are restoring.


Edited by ajkw 2015-02-23
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 12:13pm 23 Feb 2015
Copy link to clipboard 
Print this post

On the one command line you can have a maximum of 50 variables or a total line length of 255 characters so this does limit you. The variables can also be strings and using these you could easily use up the 2K space available.

I can see that limiting the command to whatever you can fit on the one command line does limit you and this was partially intended. The central issue is that VAR SAVE was not intended for saving a lot of data. Just configuration data and the like. If multiple saves were possible there would be pressure to increase the storage space and then the command would be used as a general data save facility, something that I specifically wanted to avoid so as to not exceeds the flash's endurance.

Are you being restricted by the number of variables that you want to save? Or the size of the save area? I suppose that in either case the answer would be to use an external FRAM or EPROM chip.

Geoff
Geoff Graham - http://geoffg.net
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 12:57am 24 Feb 2015
Copy link to clipboard 
Print this post

  Quote  Are you being restricted by the number of variables that you want to save? Or the size of the save area?


The 'restriction' in particular is the number of variable names you can fit into 80 columns in the editor*. It makes code hard to read/edit/debug if it is not displayed. In the example above with some average length variable names I could get 12 in before running off screen, this is my problem. In my particular program I am only using 189 bytes for 18 variables. I appreciate that saving strings could quickly consume the VAR Save area and in this regard I just save a pointer to an array of preset string data in the program. I guess if you needed to save a lot of strings then another memory chip may be required.

  Quote  ...as to not exceeds the flash's endurance

In my program I only use Var Save when a user wants to save the current state as a default state on next power up.

I think the 2K limit and a warning about flash endurance should make people think carefully about what they want to save and how often.

Anthony.

* it is noted that in the latest firmware you can increase the amount of columns which helps.
Edited by ajkw 2015-02-25
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025