Save data. It might sound complicated but once you get the hang of it the it will be really easy.
MEM files (simplest)Edit
To save a single string in a MEM file, use MEM$.
Then use SAVE "MEM:FILENAME HERE"
To load the data use LOAD "MEM:FILENAME HERE"
Now use WHATEVER$=MEM$
WHATEVER now will contain the data of the mem file. Simple, right?
MEM files with more than one thing to save (bit complicated)Edit
To save more data in a MEM file use
FOR loops and MID$ INSTR, LEFT$ and RIGHT$. Also its suggested to use seperators unless all data has a fixed length.
Use this to store data:
To get data, use this:
DAT$=MEM$ A=INSTR(DAT$,";") DATA1$=LEFT$(DAT$,A) DAT$=RIGHT$(DAT$,LEN(DAT$)-(A+1)) DATA2$=DAT$
TMP$="" A=0 FOR I=0 TO 0 IF MID$(MEM$,A,1)=";" THEN I=1GOTO@SKIP TMP$=TMP$+MID$(MEM$,A,1) @SKIP A=A+1 NEXT DATA1$=TMP$ TMP$="" FOR I=0 TO 0 IF MID$(MEM$,A,1)=";" THEN I=1GOTO@SKIP TMP$=TMP$+MID$(MEM$,A,1) A=A+1 NEXT DATA2$=TMP$
You now should have the data that was written to the MEM seperated.
Wow the one with INSTR is way shorter than the one before, thanks to uh... what was his/her name again? SquareFingers! Right, it was SquareFingers who told me to use INSTR!
GRP files (not so complicated)Edit
GRPs can store 49152 8-bit values, so they can be really useful. But they take a lot of space (49152 bytes? I don't remember). Use them when you have a lot of data to save.
To save data on a GRP, use GPSET. The other graphic commands are useless for this task.
GPSET X_COORD, Y_COORD, (0-255)
To read data, use GSPOIT(X_COORD,Y_COORD)
Optional: Use GPAGE to change the graphic page to 3, so nothing will be shown on screen.
Now for saving and loading, you will use SAVE or LOAD with the following text:
"GRP(0-3):(FILENAME HERE)" with the quotation marks.
SCR files (i suppose i'm the only person who used these to save data)Edit
Storing data in scenario files? Sweet! But they cannot hold strings, but there is 768 different tiles to store data with!
First we will store data with BGPUT:
BGPUT (0-1), X_COORD, Y_COORD, (0-767), (0-15), (0 or 1), (0 or 1)
To get the data:
BGREAD((0-1), X_COORD, Y_COORD), DATA1, DATA2, DATA3, DATA4
To save/load the data:
SAVE/LOAD "SCR(0-1):(FILENAME HERE)"
That is it? Woa.
CHR files (what! you can do that!?)Edit
Did you know that you can store a nice amount of data in a CHR file? Well now you know! The only downside is that they use hex to store data so this means the max data length is 32. But there are 256 slots in each page and there are 8 sprite pages and 4 background pages. Also there is a font page but I don't think you should use that.
First we have to convert the data to hex to be saved:
E$="" FOR I=0 TO LEN(DATA$)-1 E$=E$+HEX$=ASC(MID$(DATA$,I,1)),2) NEXT E$=LEFT$(E$+"0"*64,64)
Now we store the data in the CHR file:
CHRSET "(BGU or SPU)(0-7)",(0-255),E$
I'm pretty sure you know this arealdy, but to refresh your mind, use SAVE/LOAD "(BGU or SPU)(0-7):(FILENAME HERE)" to save the data.
Now to read the data use this:
D$="" CHRREAD((BGU or SPU)(0-7),(0-255)),R$ FOR I=0 TO 63 STEP 2 D$=D$+CHR$(VAL"&H"+MID$(R$,I,2))) NEXT D$=LEFT$(D$,INSTR(D$,CHR(0)))
Again tell me if something goes wrong.
Also if you want to store more than one string in a single slot use the same method used here. Just make sure the data doesn't exceed 32 characters or the rest will be lost!