unformatted strings (reading) [message #5722] |
Sat, 03 February 1996 00:00  |
immel
Messages: 3 Registered: February 1996
|
Junior Member |
|
|
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? Here's what is happening to me.
1)Open an unformatted idl file and write a silly string like 'stumblefloppy'
get_lun,unit
openw, unit, 'silly.dat'
writeu,unit,'stumblefloppy'
free_lun, unit
2) Try to read the string
bonk=' ' ; this is the string variable that I read into
get_lun,unit
openr, unit, 'silly.dat'
readu, unit, bonk
3) OK, I'm ready to print 'stumblefloppy'!
print,bonk
s
's' !?!? Just the first character. If I define bonk to be two spaces or three
spaces then i get 'st' or 'stu' back. I know it's cause each character is 2
bytes or something like that. Is there any way, other than defining bonk as 13
blank spaces before reading,
that I can read this string? Any bright ideas would be appreciated!
Thomas Immel
Immel@geewiz.gi.alaska.edu
P.S. Ken Knighton, whoever he is, is RIGHT ON!
|
|
|
Re: unformatted strings (reading) [message #5778 is a reply to message #5722] |
Fri, 09 February 1996 00:00  |
immel
Messages: 3 Registered: February 1996
|
Junior Member |
|
|
immel@gi.alaska.edu (Thomas Immel) wrote:
Thanks for the informative posts and E-mail.
The external data representation is just the thing
I needed to hear about. Thanks again
Thomas Immel
> 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? Here's what is happening to me.
> 1)Open an unformatted idl file and write a silly string like 'stumblefloppy'
> get_lun,unit
> openw, unit, 'silly.dat'
> writeu,unit,'stumblefloppy'
> free_lun, unit
> 2) Try to read the string
> bonk=' ' ; this is the string variable that I read into
> get_lun,unit
> openr, unit, 'silly.dat'
> readu, unit, bonk
> 3) OK, I'm ready to print 'stumblefloppy'!
> print,bonk
> s
> 's' !?!? Just the first character. If I define bonk to be two spaces or three
> spaces then i get 'st' or 'stu' back. I know it's cause each character is 2
> bytes or something like that. Is there any way, other than defining bonk as 13
> blank spaces before reading,
> that I can read this string? Any bright ideas would be appreciated!
> Thomas Immel
> Immel@geewiz.gi.alaska.edu
> P.S. Ken Knighton, whoever he is, is RIGHT ON!
|
|
|