reading_20and_20writing_20arrays_20in_20files
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
reading_20and_20writing_20arrays_20in_20files [2018/03/31 13:19] – external edit 127.0.0.1 | reading_20and_20writing_20arrays_20in_20files [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
//by Jon Ripley, May 2011//\\ \\ // | //by Jon Ripley, May 2011//\\ \\ // | ||
+ | <code bb4w> | ||
PROC_WriteArray(fileHandle%, | PROC_WriteArray(fileHandle%, | ||
PROC_ReadArray(fileHandle%, | PROC_ReadArray(fileHandle%, | ||
+ | </ | ||
\\ When reading and writing arrays you must prefix the array variable name with the address of operator, the **^** symbol, this allows us to pass all types of array to a single routine rather than requiring a separate routine for each.\\ \\ **PROC_WriteArray** writes the contents of an array to the file specified by fileHandle%.\\ \\ | \\ When reading and writing arrays you must prefix the array variable name with the address of operator, the **^** symbol, this allows us to pass all types of array to a single routine rather than requiring a separate routine for each.\\ \\ **PROC_WriteArray** writes the contents of an array to the file specified by fileHandle%.\\ \\ | ||
+ | <code bb4w> | ||
DIM array(9, 9, 9, 9) | DIM array(9, 9, 9, 9) | ||
REM Initialise array | REM Initialise array | ||
Line 10: | Line 13: | ||
PROC_WriteArray(fileHandle%, | PROC_WriteArray(fileHandle%, | ||
CLOSE# | CLOSE# | ||
+ | </ | ||
\\ **PROC_ReadArray** reads data from the file specified by fileHandle% and stores it in the specified array.\\ \\ | \\ **PROC_ReadArray** reads data from the file specified by fileHandle% and stores it in the specified array.\\ \\ | ||
+ | <code bb4w> | ||
DIM array(1000, 10) | DIM array(1000, 10) | ||
fileHandle% = OPENIN(" | fileHandle% = OPENIN(" | ||
PROC_ReadArray(fileHandle%, | PROC_ReadArray(fileHandle%, | ||
CLOSE# | CLOSE# | ||
+ | </ | ||
\\ For more information about **PROC_SwapMemory** see [[/ | \\ For more information about **PROC_SwapMemory** see [[/ | ||
+ | <code bb4w> | ||
DEF PROC_WriteArray(file%, | DEF PROC_WriteArray(file%, | ||
DEF PROC_ReadArray(file%, | DEF PROC_ReadArray(file%, | ||
Line 78: | Line 85: | ||
ENDPROC | ENDPROC | ||
+ | </ | ||
\\ Thanks to Richard Russell for the SwapMemory function.\\ | \\ Thanks to Richard Russell for the SwapMemory function.\\ | ||
---- | ---- | ||
Line 86: | Line 94: | ||
* a string target array must be empty | * a string target array must be empty | ||
\\ | \\ | ||
+ | <code bb4w> | ||
DEF PROC_WriteArray(file%, | DEF PROC_WriteArray(file%, | ||
LOCAL type%, | LOCAL type%, | ||
Line 154: | Line 163: | ||
pntr%=temp% | pntr%=temp% | ||
ENDPROC | ENDPROC | ||
+ | </ |
reading_20and_20writing_20arrays_20in_20files.1522502376.txt.gz · Last modified: 2024/01/05 00:16 (external edit)