SAVE and LOAD commands - help! - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: SAVE and LOAD commands - help! (/showthread.php?tid=1035) |
SAVE and LOAD commands - help! - RandomiserUsr - 03-08-2021 Hi I have been trying to use the SAVE command to save the data whilst the program is running, i.e. SAVE "GAME" DATA which I though would save all of the variables in the program? *Save to Virtual Cassette tape* And then I thought "All I need to do next is " LOAD "GAME" DATA and it would restore the entire game's data but it just crashes after it says "Bytes: GAME" I am sure there is something else that needs doing but can't recall this (80's memory is not as good as it should :-) ) thanks in advance RE: SAVE and LOAD commands - help! - boriel - 03-10-2021 (03-08-2021, 09:04 PM)RandomiserUsr Wrote: Hi I tried hard to implement it and it should work, but it's hard to support that feature in a compiled program. The program that saves and load the data must have the same variables declared in the same order, and you cannot use SAVE DATA / LOAD DATA from within a function or sub. Try this and if not, send me a code snippet with the SAVE / LOAD to see if I could help. RE: SAVE and LOAD commands - help! - RandomiserUsr - 03-12-2021 Thanks Boriel, The issue I found was that the SAVE/LOAD were in a function so I took them out and now it saves and loads :-) Thank you RE: SAVE and LOAD commands - help! - boriel - 03-12-2021 (03-12-2021, 10:18 PM)RandomiserUsr Wrote: Thanks Boriel, Thanks to you. The problem is related to the Heap, strings and the local variables in the stack. There's no way to recover them correctly. Sinclair BASIC didn't have proper functions and subroutines. In the future, using SAVE / LOAD DATA within functions or sub will be forbidden. The same applies for GOTO, GOSUB (don't use GOSUB within a function or sub; don't GOTO from one scope into a different one). |