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

Home » Public Forums » archive » Re: unformatted strings (reading)
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: unformatted strings (reading) [message #5719 is a reply to message #5718] Sat, 03 February 1996 00:00 Go to previous messageGo to previous message
Jackel is currently offline  Jackel
Messages: 30
Registered: April 1993
Member
In article <4eule1$si1@news.alaska.edu> immel@gi.alaska.edu (Thomas Immel) writes:
> Here's a question for anyone who reads unformatted strings.
> Is there a way to read a whole ,say 10 character, string at once
> in IDL?

Not in general. When written as standard binary, strings don't contain any
information about their length, or markers between them. Consequently, IDL
has no way of knowing how many bytes to read. However, in the XDR binary
mode, stringlengths are stored along with the string, allowing something like
the following:

IDL> teststrings= ['This','is','a','set of','test strings. Okay?']
IDL> openw,1,'test.dat',/XDR
IDL> writeu,1,teststrings
IDL> close,1

IDL> openr,1,'test.dat',/XDR
IDL> newstrings= strarr(5) ;define some strings, don't worry about their lengths
IDL> readu,1,newstrings
IDL> print,newstrings
This is a set of test strings. Okay?

Of course, this is only useful if you can make sure XDR is used in the first
place (and if you had control over the writing you could just pad everything
out to some known length). Otherwise you can try things like searching for
spaces (like another poster suggested), but that could get messy if there are
non-strings mixed in with the data. Good luck.

Brian Jackel
University of Western Ontario
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: LINKIMAGE under hpux
Next Topic: Re: Scientific Notation on Log Plots

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

Current Time: Wed Oct 08 19:16:49 PDT 2025

Total time taken to generate the page: 0.00525 seconds