| Re: Create unique temporary file [message #40789 is a reply to message #40674] |
Wed, 25 August 2004 17:10  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Michael Wallace <mwallace.no.spam@no.spam.swri.edu.invalid> writes:
>> 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. ;-)
Hey Michael, I'm coming into this late, but I've developed a function
called CMUNIQUE_ID() which generates unique identifiers. I use it all
the time to avoid name clashes. I bases the unique ID on the time,
some randomness, and any other bits you can throw at it. Each time you
ask for another ID, you get a different one. [ It works even if you
ask for two IDs within the same second, which might not work if one
uses SYSTIME() alone. ]
Good luck,
Craig
http://cow.physics.wisc.edu/~craigm/idl/idl.html (under Misc.)
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
|