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

Home » Public Forums » archive » Re: Create unique temporary file
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: Create unique temporary file [message #40669] Wed, 25 August 2004 06:54 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Michael Wallace wrote:
>> Here is how I create a unique journal file name:
>>
>> Print, String('journal_', Bin_Date(SysTime()), '.pro', $
>> Format='(A, I4, 5I2.2, A)')
>
>
> Thanks for the idea. I had thought of using a current system time
> stamp, but it totally slipped my mind that I could concatenate the
> number together so easily. It's little details like that which I'm
> still learning. When I finally wrote my code, not only did I take the
> date as you did, but I further appended a random number and I did a
> check of file existence to ensure that nothing would ever get clobbered.
> The only way this could fail would be if there were some insane
> once-in-a-lifetime freakish occurrence. Now that I've said this, this
> will happen tomorrow. ;-)

I do a similar thing in some shell scripts I have, but I append a sequential number rather
than a random number. E.g. I start with my time (and username!) stamped file and append a
"_1". I check if that file exists. If it does I change the suffix to "_2". Rinse and
repeat as necessary. If the file counter gets larger than 100, I stop with an error.

I've had the number suffix get as high as 15 - i.e. the line of code in my script that
compiles the time stamped filename was executed simultaneously 14 times. Ahh, the joys of
having 100's of processors to play with. :o)

paulv
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Another EPS question
Next Topic: Create unique temporary file

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

Current Time: Sun Nov 30 09:01:42 PST 2025

Total time taken to generate the page: 3.92765 seconds