Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:58 21 Nov 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 / VAR RESTORE

Author Message
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 03:57pm 04 Nov 2022
Copy link to clipboard 
Print this post

Hi,
I try to use the two commands VAR SAVE and VAR RESTORE without success. First I enter VAR CLEAR from the console. Then I run the program. After that I make the marked lines as comment and start the program a second time. However, the array rline() is not present. What am I doing wrong?


'''''''''''''''''''''''''''''''''''''
' Test: VAR SAVE vars, VAR RESTORE
'
' 4.11.2022: VAR RETORE ????
' '''''''''''''''''''''''''''''''''''
'
option base 1
dim string rline(5) length 12
dim i as integer
var restore                   '??
'                                             'should not be necessary:
if left$(rline(1),1) = "" then                'comment out for second run
 for i=1 to 5                                'comment out for second run
   rline(i) = str$(i) + ".  Name " + str$(i) 'comment out for second run
   print rline(i)                            'comment out for second run
 next i                                      'comment out for second run
 var save rline()                            'comment out for second run
end if                                        'comment out for second run
'
print
print "rline() restored:"
print rline(1)                '??
print
'
end
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4147
Posted: 04:16pm 04 Nov 2022
Copy link to clipboard 
Print this post

Would be good to say what hardware (CPU) & what MMBasic version :)

John
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8304
Posted: 05:22pm 04 Nov 2022
Copy link to clipboard 
Print this post

Have you tried doing the second run without dimensioning rline()?
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10628
Posted: 05:32pm 04 Nov 2022
Copy link to clipboard 
Print this post

Tried your program on PicoMite V5.07.05RC8 and it works perfectly

  Quote  Have you tried doing the second run without dimensioning rline()?


That will give an error. Arrays must be dimensioned to use restore
Edited 2022-11-05 03:32 by matherp
 
Bowden_P
Senior Member

Joined: 20/03/2019
Location: United Kingdom
Posts: 162
Posted: 08:45pm 04 Nov 2022
Copy link to clipboard 
Print this post

To demonstrate the non-volatility of a VAR SAVE/RESTORE sequence, you need to power-down/power-up between your first and second runs. However, do NOT reload your program, else you will erase your SAVE'd variables! Just do the commenting edits, then run it.
With best regards, Paul.

p.s. This only applies when using the internal editor.
If you are editing using MMEdit, a download occurs for your edits to run, which will erase the previously SAVE'd vars.
Edited 2022-11-05 06:51 by Bowden_P
Nothing so constant as change.
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 09:37pm 04 Nov 2022
Copy link to clipboard 
Print this post

  Bowden_P said  
p.s. This only applies when using the internal editor.
If you are editing using MMEdit, a download occurs for your edits to run, which will erase the previously SAVE'd vars.


It's been awhile so please correct me if I'm wrong but I seem to remember that; select/copy the code in MMEdit, go to the prompt in MMC, type Autosave(is that right?), Enter.
Then paste the code at the prompt and terminate with CTRL-Z

I believe that this only replaces the code....but I could be wrong  


Craig
 
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 10:31am 05 Nov 2022
Copy link to clipboard 
Print this post

Thank you all!
Sorry about missing infos. My trials run on a Pi Pico. Firmware of MMBASIC ist V5.07.04 and I'm using MMEDIT 5 together with MMCC. I will flash the newest firmware V5.07.05RC9 and look what happens.
 
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 02:10pm 05 Nov 2022
Copy link to clipboard 
Print this post

Just tested the program with firmware V5.07.05RC9 and on two different Pi Pico's. Found the same behavior as with V5.07.04. At the moment I have no idea how to use VAR SAVE/RESTORE.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10628
Posted: 02:57pm 05 Nov 2022
Copy link to clipboard 
Print this post

The issue is that you are updating the program with MMEDIT. This uses AUTOSAVE to download the program. This erases all cleared variables as does any mechanism of loading a new program. Don't edit your program to comment out the lines. Just run it twice in a row and it will work as you want
 
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 10:47am 06 Nov 2022
Copy link to clipboard 
Print this post

I have simplified the program. When I run it twice, the values from the first run are gone. I did not edit the program between the two runs. What happened?

'''''''''''''''''''''''''''''''''''''
' Test: VAR SAVE vars, VAR RESTORE
'       start the program two times
'
' 6.11.2022: VAR RETORE ????
' '''''''''''''''''''''''''''''''''''

print "Version:" , print mm.ver
print
'randomize                                'gives an error?
dim a,b,c as integer

var restore                               'restoring values from the first run
print "First run:   "; a;"   ";b;"   ";c  'where are these values? !not zero!

a=int(100*rnd)
b=int(100*rnd)
c=int(100*rnd)
var save a,b,c                            'please, save the values
print
print "Second run   "; a;"   ";b;"   ";c

end
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10628
Posted: 11:02am 06 Nov 2022
Copy link to clipboard 
Print this post

Don't know what you are doing wrong. Are you reloading the program between runs with MMEdit. Tested as below using Teraterm

 
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 01:32pm 06 Nov 2022
Copy link to clipboard 
Print this post

It is a shame. You are absolutely right. It's obviously a bad habit of mine to press the rightmost icon in MMEdit, because it means exactly what it is, "load file and run it". Once again, it's a shame. Sorry for the time you spent.

Nevertheless, with the picture, you saved the situation for me. Thank you very much.
 
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