[Gambas-user] Read and arrays

Benoît Minisini gambas at ...1...
Tue Mar 13 00:08:41 CET 2012


Le 12/03/2012 17:21, tobi a écrit :
> On Mon, 12 Mar 2012, Jussi Lahtinen wrote:
>
>> I was thinking quicker way to read large binary files to memory.
>> And I noticed this; "The returned datatype can be one of the following:
>> NULL, Boolean, Byte, Short, Integer, Long, Pointer, Single, Float, Date,
>> String, Variant, any Array, Collection or structure".
>> http://gambasdoc.org/help/lang/read?v3
>>
>> So, I wonder whether it is quicker to read data as array, instead of
>> looping one (short) integer at time.
>>
>> But how to do that? Did I misunderstand something?
>>
>>
>> tmpArr = Read hFile As Short[2000]
>>
>> Doesn't compile (unexpected '[')... or does this work only for data written
>> as array, and read as Short[] without given bounds?
>>
>>
>> Jussi
>
> i once watched the format of files to which arrays/collections were written. they consist, if i
> remember correctly, of an identifier followed by the size and then the data.
> if you write an array to a file you can only read that array back, i think.
> so it works on datatype base, not on raw memory base if you Read As Datatype. reading as much as
> possible in one call is definitely faster (that is the reason for which the standard libc streams are
> buffered by default). reading raw memory arrays of fixed size may be done using memory streams...?
> do they persist in gambas3? i can't check anything now.
>
> regards,
> tobi
>

Arrays have Read() and Write() methods to read/write their contents 
from/to the disk.

Regards,

-- 
Benoît Minisini




More information about the User mailing list