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

Home » Public Forums » archive » FORMAT codes and tabs
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: FORMAT codes and tabs [message #15407 is a reply to message #15373] Fri, 14 May 1999 00:00 Go to previous messageGo to previous message
Justin Ashmall is currently offline  Justin Ashmall
Messages: 15
Registered: May 1999
Junior Member
Thanks very much for the effort - it certainly looks like you got the
answer.
I think my best bet would be to read the line into a string, replace all the
slashes with spaces and then use a single format, along the lines of

b_line = BYTE(line)
list = WHERE(b_line EQ (BYTE("/"))[0], count)
if count GT 0 then b_line[list]=(BYTE(" "))[0]
line = STRING(b_line)

Then use a general FORMAT statement with "I0"'s.
However I've not tried that yet!

Thanks again,

Justin.

Steven Thiel <beorabor@bemail.com> wrote in message
news:373B0402.E4155882@bemail.com...
> J. Ashmall:
>
> I think I know why IDL is behaving as it is, but really don't have an
> answer to how you can read both types of lines using the same format
> code. I entered a few commands at the command prompt:
> --
> IDL> line1 = '10/11/99' + STRING(9b) + ' 19 : 42'
> IDL> READS, line1, FORMAT='(I0,x,I0)', dd,mm
> IDL> help, dd, mm
> DD INT = 10
> MM INT = 19
> --
> This format does give us back two integers, but they are the wrong ones.
> We get back the 10 from the date and the 19 from the time. When you use
> the format code I0, IDL differentiates the elements to be read using
> white space. It applies the code I0 to the first element it finds- in
> this case this is '10/11/99'. If you tell IDL to FIX this string, you
> get:
> ---
> DL> HELP, FIX('10/11/99')
> <Expression> INT = 10
> ---
> After reading the '10/11/99', IDL moves on to the next element. In this
> case, it is the '19'. If we try and read in all elements, we get the
> following:
> ---
> IIDL> READS, line1, FORMAT='(I0,x,I0,x,I0)', dd,mm,yy
> % Unable to apply format code I to input: ": 42".
> % Execution halted at: $MAIN$
> ---
> After reading the first two elements, it moves on to the third- ': 42'.
> This one it cannot convert to the input format of integer:
> ---
> IDL> HELP, FIX(': 42')
> % Type conversion error: Unable to convert given STRING to Integer.
> % Detected at: $MAIN$
> <Expression> INT = 0
> ---
> Because you have other string characters in your input (the '/'), I don't
> really know how you would go about finding a general input format code.
> My suggestion would be to just read the whole thing in as a string,
> STRCOMPRESS it and STR_SEP it by single spaces. You will end up with an
> array that has the date as the first element, the hour as the second
> element, a ':' as the third and the minutes as the last. I know this
> will require more processing and isn't very clean, but I don't know of
> any other solution. I would be interested to know if someone does figure
> this out.
>
> Hope this helps.
>
> S.Thiel
> beorabor@bemail.com
> ------------------
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: CALL_EXTERNAL on Debian Linux
Next Topic: Special Characters

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

Current Time: Sun Oct 12 02:34:39 PDT 2025

Total time taken to generate the page: 1.12271 seconds