Re: Can you do 'unions' with pv-wave? [message #3179 is a reply to message #3177] |
Mon, 21 November 1994 17:08  |
hahn
Messages: 108 Registered: November 1993
|
Senior Member |
|
|
In article <1994Nov19.012318.9400@mksol.dseg.ti.com> jgavin@mksol.dseg.ti.com (Jeffrey S. Gavin) writes:
> From: jgavin@mksol.dseg.ti.com (Jeffrey S. Gavin)
> Subject: Can you do 'unions' with pv-wave?
> Date: Sat, 19 Nov 1994 01:23:18 GMT
> Is there a way to have a single variable viewed as multiple types, similar
> to the way unions work in C. For example:
[example deleted]
> Our brute-force approach is to read the 50MB file in once as an array of bytes, then again as an array of int, float, then double. This takes time and space
> when actually, we simply want to view the same exact data in different ways.
> Again, the 'C' union structure is the best way I can describe the problem.
> Thanks for any help.
> Regards,
> Jeff
> --
> Jeff Gavin Jeff.Gavin@dseg.ti.com
> Texas Instruments MSG: JGAV / (214) 462-5496
The predefined approach to this problem is to read the data in pieces into a
string array or string and use reads to retrieve data from the string using a
fortran style format. Example (not tested) which assumes your data file on disk
is open:
temp_s = String ('*', format='(A200)') ; declare a 200 byte string
c2 = '**' ; declare a 2 byte character item
i2 = 0 ; declare a short integer variable
readu, iunit, temp_s ; read 200 bytes from disk
reads, temp_s, c2 ; read into a string variable
reads, temp_s, i2 ; read the same data into a short integer variable
... hope this helps
Norbert
|
|
|