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

Home » Public Forums » archive » Re: FORMAT codes and tabs - why not use STR_SEP?
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 - why not use STR_SEP? [message #15366 is a reply to message #15352] Mon, 10 May 1999 00:00 Go to previous message
Robert King is currently offline  Robert King
Messages: 9
Registered: March 1999
Junior Member
Justin Ashmall <ashmall@my-dejanews.com> wrote in article
<3736e5d7.252843619@news.cc.ic.ac.uk>...
>
> 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.


Dear Justin,

I've tried out your program and understand what you're trying to do (I
think :-). However, I think that you'd have less trouble by doing it using
strings and STR_SEP.

I've only read line2 so that you can see the workings easier, but it works
for line1 as well, in fact, it'll work no matter how many digets the
day,month or year has.

Hope this is so some help :-)

Robert
___________________




Pro test_read_too

;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'

;Read line2 as a string

textline=''
READS, line2, textline
print, 'line 2 =', textline

;Use STR_SEP to break up the line into the date elements.

date = STR_SEP( textline , '/' )
help, date

day = date(0)
month = date(1)

;The last part [date(2)] will contain the year, tab and time so break
this up
;this time looking for spaces rather than slashes.

rest = STR_SEP( date(2), ' ' )
year = rest(0)

;Print out the full date

print, day
print, month
print, year

;You could continue to get the time as well

END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: AMD processor and IDL
Next Topic: Re: coherence test implementation

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

Current Time: Fri Oct 10 04:27:27 PDT 2025

Total time taken to generate the page: 0.47940 seconds