comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Null terminated strings
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Null terminated strings [message #28673] Mon, 07 January 2002 18:26 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
James Kuyper <kuyper@gscmail.gsfc.nasa.gov> writes:

> I'm reading a string-valued file attribute from an HDF file that was
> created using C code. As seems quite reasonable for C programs, the
> attribute was written with a length that includes a terminating null
> character. When I read it in using IDL, that null character got included
> as well. This causes a number of bizarre effects, most notably:
>
> IDL> print,date
> 2001-10-07
> IDL> print,date+'T12:00:00'
> 2001-10-07'T12:00:0
>
> I can handle this particular case by using strmid(date,0,10), but in
> general a file attribute might contain multiple null-delimited strings,
> of unknown length. Is there an efficient way of converting such a string
> into an IDL string array?

What happens when you swizzle it through a STRING-BYTE-STRING
transformation?

I.e.,

date = string(byte(date))

I believe that STRING will ignore any trailing 0-bytes, hence this may
solve your problem exactly, at the expense of some extra CPU.

Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Finding a structure in a structure
Next Topic: where is idl-fortran.Z by Jeff Valenti

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 05:15:37 PDT 2025

Total time taken to generate the page: 0.48210 seconds