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

Home » Public Forums » archive » Re: Reading a string from a file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Reading a string from a file [message #13808] Thu, 10 December 1998 00:00
Franz.Dollinger is currently offline  Franz.Dollinger
Messages: 14
Registered: July 1997
Junior Member
Franz.Dollinger@REMOVE_THIS.mchp.siemens.de (Franz Dollinger):
> davidf@dfanning.com (David Fanning):
>>
>> If your file is a binary file, make sure you are
>> writing an XDR file. These files will save the
>
> I'll take the chance to jump on this thread with a
> followup question:
> I'm using XDR for a while with PV-WAVE.
> Now I have to exchange data btween PV-WAVE and C programs.
> Is there a library in C for reading and writing XDR
> available somewhere?
>

Sorry for pushing send to fast:
I guess I have to be more precise. I'm looking for a library
that works on NT with C++. It looked to me like RPC is not
included with every compiler. (wrong installation?)

thanks again

bye
Franz


--
Standard->disclaimer
(You didn't really think the opinions expressed herein
are in any way related to my employer?)
Email: Please remove REMOVE_THIS from
Franz.Dollinger@REMOVE_THIS.mchp.siemens.de
Re: Reading a string from a file [message #13809 is a reply to message #13808] Thu, 10 December 1998 00:00 Go to previous message
Franz.Dollinger is currently offline  Franz.Dollinger
Messages: 14
Registered: July 1997
Junior Member
davidf@dfanning.com (David Fanning):
>
> If your file is a binary file, make sure you are
> writing an XDR file. These files will save the

I'll take the chance to jump on this thread with a
followup question:
I'm using XDR for a while with PV-WAVE.
Now I have to exchange data btween PV-WAVE and C programs.
Is there a library in C for reading and writing XDR
available somewhere?

Thanks for any help.

bye
Franz

--
Standard->disclaimer
(You didn't really think the opinions expressed herein
are in any way related to my employer?)
Email: Please remove REMOVE_THIS from
Franz.Dollinger@REMOVE_THIS.mchp.siemens.de
Re: Reading a string from a file [message #13817 is a reply to message #13808] Wed, 09 December 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Stefano Manzonetto (tesi3@a5.itba.mi.cnr.it) writes:

> I've a problem which should rather easy for you to solve. I need to
> save a string to a file and then read it without knowing before its
> length. Note that the string is just a field of a struct, so I can't get
> its length from the file's one.

If your file is an ASCII file, put the string on a line
by itself and read it like this:

mystring = ''
ReadF, lun, mystring

If your file is a binary file, make sure you are
writing an XDR file. These files will save the
length of a string along with the other "meta" data.

OpenW, lun, 'myfile.dat', /Get_Lun, /XDR

If you want to write a binary file, but for some
reason you can't use XDR format, then the best idea
is to write the length of the sting into the file.
Something like this:

WriteU, lun, StrLen(mystring), mystring

Then, when reading out:

stringLen = 0L
ReadU, lun, stringLen
mystring = String(Replicate(32B, stringLen))
ReadU, lun, mystring

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Progamming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155

[Note: This follow-up was e-mailed to the cited author.]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: LINKIMAGE/CALL_EXTERNAL/DLM advice
Next Topic: XDISPLAY

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

Current Time: Fri Oct 10 08:32:55 PDT 2025

Total time taken to generate the page: 0.47729 seconds