|
Forum Index : Microcontroller and PC projects : Help with Micromite VAR SAVE and VAR RESTORE functions
| Author | Message | ||||
| Bob339 Newbie Joined: 28/02/2021 Location: United StatesPosts: 4 |
I have been trying to save some variables to the Micromite flash memory, but cannot get it to work. I am using the following two programs. [code} A$ = "Hello World" VAR Save A$ {/code} I save the above code, power off the Micromite, turrn it back on and run the following code: [code] VAR RESTORE PRINT A$ [/code] The second program outputs nothing. Can someone tell me why this doesn't work. |
||||
| circuit Senior Member Joined: 10/01/2016 Location: United KingdomPosts: 293 |
Should work okay; it works for me. Just to make sure that I had not missed something I just quickly typed it in, powered down, powered up and there it was. Please tell us which Micromite you are using and which MMBasic version? |
||||
| circuit Senior Member Joined: 10/01/2016 Location: United KingdomPosts: 293 |
Just a further thought; when you said "I save the above code..." I presume that you did RUN the code after saving it before you powered down? p.s. As this is your first post (I have just noticed) a warm welcome to the forum. This is one of the most helpful and polite places to get help on your projects. I have gained enormously from consulting the many knowledgeable contributors around the globe. Edited 2022-09-04 05:32 by circuit |
||||
| Bob339 Newbie Joined: 28/02/2021 Location: United StatesPosts: 4 |
Hello circuit Sorry for the delay getting back. Had some problems logging back in. I am using the Micromite MX170F2568 chip and MMBasic version 5.05.03. Yes, I did RUN the code after saving it, but just to be sure I ran and saved it again, but still no response. I also tried using a different MX170 chip, but still no resonse. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10628 |
Can't remember exactly but I think loading a new program erases the saved variables. The intention is that a single program can save data for the next time it is run without re-loading. Try your commands at the command line to start with. |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2832 |
Hi Bob, At the console:- > ? mm.ver 5.0505 > ? mm.device$ Micromite MkII > a$="Hello World" > ? a$ Hello World > var save a$ Power off, wait 30s power on. > Micromite MKII MMBasic Ver 5.05.05 Copyright 2011-2021 Geoff Graham > var restore > ?a$ Hello World > a$ = "Deleted" > ? a$ Deleted > var restore > ? a$ Hello World > NEW deletes everything belonging to the previous program including VARs. |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
Saved variables are indeed cleared by the NEW command or when a new program is loaded via AUTOSAVE, XMODEM, etc. This is because the VAR SAVE command is intended for saving data that will be used later by the same program. Try running this program twice: VAR RESTORE PRINT A$ A$ = "Hello World" VAR Save A$ The first time that you run it, nothing will be printed on the console. The second time that you run it you should see "Hello World". Geoff Edited 2022-09-04 08:09 by Geoffg Geoff Graham - http://geoffg.net |
||||
| Bob339 Newbie Joined: 28/02/2021 Location: United StatesPosts: 4 |
Hello Geoff, I tried your suggestion of running the program twice, but get no resonse I tried matherp's suggestion and got error cant find A I tried phil99's suggestion and got error flash write I am using MMEdit. Should that make any difference. |
||||
| Bob339 Newbie Joined: 28/02/2021 Location: United StatesPosts: 4 |
Sorry Guys I had not used the Micromite for a while and forgot some things. I tried Geoff's suggestion again and hit the run button. It Worked. The problem was that I was not hitting the run button. Thanks much, I might have given up without your help. |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9757 |
Glad you got it sorted, and welcome to the forums. ![]() Please do continue to post any questions. This forum is very welcoming to newbies, and once you get into MMBASIC, I think you will like it quite a lot. Pardon my presumptuousness. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |