IonicWind Software

Creative Basic => General Questions => Topic started by: GWS on January 21, 2012, 01:24:37 PM

Title: Writing arrays to files
Post by: GWS on January 21, 2012, 01:24:37 PM
Hi,

It isn't very clear in the users guide, but ..

WRITE with a BFILE and an array, will write the entire array to the disk file.

READ with a BFILE and an array, will read the entire array in one shot.
                     
If you use a subscript on the array variable, the reading/writing takes place at that location in the array.

A short pseudo code example:
               
DEF a[100]:int
DEF b:BFILE

if OPENFILE(b......
   WRITE b,a[0]: Rem writes all 100 elements of a
   READ b,a[0]: REM reads all 100 elements of a
             ...
etc.                     
                 
If you need to read/write a single element from the array, use a temporary variable to copy to and from the
array.

all the best, :)

Graham                     
                     
Title: Re: Writing arrays to files
Post by: LarryMc on January 21, 2012, 05:00:21 PM
neat; I didn't realize that Graham.

LarryMc
Title: Re: Writing arrays to files
Post by: GWS on January 21, 2012, 07:07:24 PM
 ;D .. just came across it in some old notes ..

Quite a few interesting things .. I'll see if I can find anything else ..

best wishes, :)

Graham