Re: Reading structure from array [message #44536] |
Mon, 20 June 2005 18:35 |
Robert Moss
Messages: 74 Registered: February 1996
|
Member |
|
|
photosalex@freenetname.co.uk wrote:
> Hello, All!
>
> Could anyone suggest how to read a pre-defined structure containing
> variables and 2-D arrays from a source array? It's very simple to read
> such a structure from a file, using READU. Is there any way to do it
> with an array without explicitly specifying the indices of the sorce
> and target variables/arrays (this is gonna be too messy).
>
> Thanks a lot!
>
Write the source array to a temporary file as bytes (assuming it is not
already in a file), and read it back in using the structure definition
in the READF call. Something along these lines:
openw, lu, tmpfile, /get_lun
writeu, lu, data
free_lun, lu
openr, lu, tmpfile, /get_lun
readu, lu, struct
free_lun, lu
file_delete, tmpfile, /quiet
return, struct
--
Robert Moss, PhD
|
|
|