|
Re: Return the name of the last (newest) file ? [message #31670 is a reply to message #31669] |
Tue, 13 August 2002 11:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
>
> It's telling you the variable is an array, and it should
> be a scalar. It happens to be an array with only one element
> in it, however, so use it like this:
>
> data=read_ascii(lastfile[0],data_start=1)
Whoops, sorry. I hit that SEND button before I meant to.
I was going to tell you that it is not uncommon to get
arrays back from string routines, and often arrays of
a single element. This probably has to do with how
strings are stored internally in routines, but it's
mostly lazy programming, it seems to me. In *your* programs,
you are going to do something like this:
IF N_Elements(returnString) EQ 1 THEN RETURN, returnString[0] ELSE $
RETURN, returnString
Then your user won't have to worry about this perfectly
true, but less than illuminating error message. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Return the name of the last (newest) file ? [message #31671 is a reply to message #31670] |
Tue, 13 August 2002 11:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Kolbjorn Bekkelund (kobe@rocketrange.no) writes:
> Thanks for the tip.
> I tried it and the print command shows the correct file, but:
> When I try to use the contents of lastfile as an input like
>
> data=read_ascii(lastfile,data_start=1)
>
> I get:
>
> MESSAGE: Expression must be a scalar in this context: <STRING
> Array[1]>
>
> I got the same earlier today when I tried to use the spawn, 'date',
> mydate. I solved that one by using systime() though. What is it telling
> me ?
It's telling you the variable is an array, and it should
be a scalar. It happens to be an array with only one element
in it, however, so use it like this:
data=read_ascii(lastfile[0],data_start=1)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: Return the name of the last (newest) file ? [message #31673 is a reply to message #31672] |
Tue, 13 August 2002 10:09  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Kolbjorn Bekkelund (kobe@rocketrange.no) writes:
> I'm modifying an old IDL-routine (under Linux and IDL 5.4), plotting some of our ozone lidar data.
> This has to be done manually today, but I'm working against an automation
> of this job now. The final stage here is to have IDL run by cron, finding the last
> (newest) file by itself and process it.
>
> Now I'm using this approach:
>
> FileTable=dialog_pickfile(/read, filter='/data/ozon/dialdata/ozon-online/*')
>
> which isn't very automatic :-)
No. :-)
I think you are going to have to use FindFile to
get your list of files. Then you are going to have
to sort the list. You DON'T want to use the IDL
SORT command to do that, since a unique sort order
is not guaranteed. Have a look at the BSORT
command from the NASA astronomy library. (Perhaps
someone could provide a link, I don't have it at
the moment.) With luck, that will be enough and you
won't have to resort to more aggressive string processing
techniques.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Return the name of the last (newest) file ? [message #31674 is a reply to message #31673] |
Tue, 13 August 2002 10:05  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
Kolbjorn Bekkelund wrote:
>
> Hi.
>
> I'm modifying an old IDL-routine (under Linux and IDL 5.4), plotting some of our ozone lidar data.
> This has to be done manually today, but I'm working against an automation
> of this job now. The final stage here is to have IDL run by cron, finding the last
> (newest) file by itself and process it.
>
> Now I'm using this approach:
>
> FileTable=dialog_pickfile(/read, filter='/data/ozon/dialdata/ozon-online/*')
>
> which isn't very automatic :-)
>
> The structure of the filesystem is like this:
>
> /data/ozon/dialdata/ozon-online/
>
> and a listing of that directory gives:
>
> [kolbjorn@antares ozon-online]$ ls
> AUG12_02.001 AUG12_02.008 AUG12_02.015 AUG12_02.022 AUG12_02.029
> AUG12_02.002 AUG12_02.009 AUG12_02.016 AUG12_02.023 AUG12_02.030
> AUG12_02.003 AUG12_02.010 AUG12_02.017 AUG12_02.024 AUG12_02.031
> AUG12_02.004 AUG12_02.011 AUG12_02.018 AUG12_02.025 AUG12_02.032
> AUG12_02.005 AUG12_02.012 AUG12_02.019 AUG12_02.026 AUG12_02.033
> AUG12_02.006 AUG12_02.013 AUG12_02.020 AUG12_02.027 AUG13_02.034
> AUG12_02.007 AUG12_02.014 AUG12_02.021 AUG12_02.028
>
> I would be very happy for all the help I could get !
How about this?
spawn, 'ls -1rt /data/ozon/dialdata/ozon-online | tail -1', lastfile
print, lastfile
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|