|
Forum Index : Microcontroller and PC projects : VAR SAVE / VAR RESTORE
| Author | Message | ||||
| rea23 Newbie Joined: 16/09/2022 Location: SwitzerlandPosts: 26 |
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 "rline() restored:" print rline(1) '?? ' end |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4147 |
Would be good to say what hardware (CPU) & what MMBasic version :) John |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8304 |
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 KingdomPosts: 10628 |
Tried your program on PicoMite V5.07.05RC8 and it works perfectly 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 KingdomPosts: 162 |
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 KingdomPosts: 1646 |
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: SwitzerlandPosts: 26 |
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: SwitzerlandPosts: 26 |
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 KingdomPosts: 10628 |
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: SwitzerlandPosts: 26 |
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 '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 "Second run "; a;" ";b;" ";c end |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10628 |
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: SwitzerlandPosts: 26 |
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. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |