| Re: how to define a struct header of fixed length in IDL [message #44846] |
Sun, 17 July 2005 11:15 |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
rzsh5 wrote:
> hi,all
> I have met a problem in write a binary file in IDL. In my output
> file, I need to write a header with 1024 byte length first, and then
> output the data(5*5). I have defined a struct array for the header
> which includes different data types (string, Long, Integer), But how to
>
> define a string type variable with fixed length, for example, char*
> a[20]? my header is just like the following, but I can't read it out.
> please help me, thanks.
> struct={header,
> Sat:'',Product:'',Unit:'',Year�:1,Day:1,Hour:1,Mini:1,L at_max�:1.0,Lat_min:1.0,Lon_max:1.0,L�on_min:1.0,P roject:'',R_lat:1.�0,R_lon:1.0,Row:1,Col:1,Slope:� 1.0,Offset:1.0,spare:''}
>
> where, for Sat,Product and Unit, Project, The length is char*20.
>
>
> I use writeu to write the header into file, and readu to get the header
>
> out, but failed.
>
How about using byte arrays of fixed length? You could write a wrapper
routine which converts strings to byte arrays (of fixed length) when
writing and vice versa when reading.
Benjamin
|
|
|
|