storing_20structures_20containing_20strings
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
storing_20structures_20containing_20strings [2018/03/31 13:19] – external edit 127.0.0.1 | storing_20structures_20containing_20strings [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
===== Writing the structure ===== | ===== Writing the structure ===== | ||
\\ To copy the strings into temporary variables, which should be made **LOCAL** inside your save routine, and clear the strings use code similar to the following: | \\ To copy the strings into temporary variables, which should be made **LOCAL** inside your save routine, and clear the strings use code similar to the following: | ||
+ | <code bb4w> | ||
temp1$ = struct.string1$ | temp1$ = struct.string1$ | ||
temp2$ = struct.string2$ | temp2$ = struct.string2$ | ||
- | etc... | + | |
struct.string1$ = "" | struct.string1$ = "" | ||
struct.string2$ = "" | struct.string2$ = "" | ||
- | etc... | + | |
+ | </ | ||
\\ Here each string in the structure is copied into a temporary string and each string in the structure is set to a NULL string (**"" | \\ Here each string in the structure is copied into a temporary string and each string in the structure is set to a NULL string (**"" | ||
+ | <code bb4w> | ||
PTR#file% = temp% | PTR#file% = temp% | ||
SYS " | SYS " | ||
PRINT# | PRINT# | ||
+ | </ | ||
\\ Here the file buffers are flushed, the structure is written to the file and the temporary copy of each string is written to the file.\\ \\ To copy the strings back into the structure use code similar to the following: | \\ Here the file buffers are flushed, the structure is written to the file and the temporary copy of each string is written to the file.\\ \\ To copy the strings back into the structure use code similar to the following: | ||
+ | <code bb4w> | ||
struct.string1$ = temp1$ | struct.string1$ = temp1$ | ||
struct.string2$ = temp2$ | struct.string2$ = temp2$ | ||
- | etc... | + | |
+ | </ | ||
\\ | \\ | ||
==== Reading the structure ==== | ==== Reading the structure ==== | ||
\\ To load the structure from the file use code similar to the following: | \\ To load the structure from the file use code similar to the following: | ||
+ | <code bb4w> | ||
PTR#file% = PTR#file% | PTR#file% = PTR#file% | ||
SYS " | SYS " | ||
INPUT# | INPUT# | ||
+ | </ | ||
\\ Here we flush BASIC' | \\ Here we flush BASIC' |
storing_20structures_20containing_20strings.1522502384.txt.gz · Last modified: 2024/01/05 00:16 (external edit)