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
FORMAT codes and tabs [message #15373] Mon, 10 May 1999 00:00 Go to previous message
ashmall is currently offline  ashmall
Messages: 14
Registered: October 1998
Junior Member
Dear All,

I'm having trouble reading in a text file with dates and times in the
form:
11/10/99<tab><sp>16<sp>:<sp>47
where <tab> and <sp> represent tabs and spaces.
Sometimes the day/months are consist of only 1 char (e.g. 3/4/99). I
can write a separate FORMAT statement for each case but when I try to
use I0 to deal with both cases it doesn't work and it seems to be due
to the TAB char.
Am I just being foolish or what?
The following short program might hepl explain. I'm using IDL 5.2
under NT4.0.

Cheers,

Justin

pro test_read

;Create a Tab character
tab = STRING(9B)
;Create 2 lines of dummy input
line1 = '10/11/99' + tab + ' 19 : 42'
line2 = '1/3/99' + tab + ' 19 : 42'

;This format works for days/months with 2 digits
READS, line1, FORMAT='(I2,x,I2,x,I2,2x,I2,3x,I2)', dd,mm,yy,hh,mn
print, dd,mm,yy,hh,mn

;This format works for days/months with 1 digit
READS, line2, FORMAT='(I1,x,I1,x,I2,2x,I2,3x,I2)', d,m,yy,hh,mn
print, d,m,yy,hh,mn

;How to use the same format code for both line1 and line2?
;Presumably need to use I0 to automatically adjust to different
;widths.

;Just trying to read in the first 3 numbers (the date)
READS, line1, FORMAT='(I0,x,I0)', dd,mm ;This works
print, dd,mm
READS, line1, FORMAT='(I0,x,I0,x,I0)', dd,mm,yy ;This DOESN'T work
READS, line1, FORMAT='(I0,x,I0,x,I2)', dd,mm,yy ;This DOESN'T work
;Is there something strange going on with the tab character?

end
[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: Fri Oct 10 11:57:12 PDT 2025

Total time taken to generate the page: 0.87986 seconds