Hi Chris,
> I use a script that needs a unique filename to write out
> data into text files. So, I just had it concat the
> hour/min/sec together and use that, figuring, "What are
> the chances of the script running at the same time, to
> the second, twice?"
Hehehehehehe.
If the name isn't that important you can append a GUID. Here's my
GUIDGenerator:
'// ========================================================
Function NewGuid()
Dim oGUID, sGuid
Set oGUID = Server.CreateObject("scriptlet.typelib")
sGuid = Trim(oGUID.guid)
Set oGUID = Nothing
sGuid = Trim(Replace(sGuid, " ", ""))
sGuid = Trim(Replace(sGuid, "{", ""))
sGuid = Trim(Replace(sGuid, "}", ""))
sGuid = Trim(Replace(sGuid, "-", ""))
sGuid = Mid(sGuid, 1, 32)
NewGuid = sGuid
End Function
'// ========================================================
I've also been known to use a shorter version I call a 'HUID' that
is essentially a GUID that is compatible with the http addressing
scheme. IOW, it's "okay" to use all the characters within it in a
URL (though not a file name :). Here's my code for that:
'// ========================================================
Function NewHuid( sGUID )
Dim sHid, sBlock, lBlock, lAt, hi, lo, sBuild
Const ksB64 = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" _
& "abcdefghijklmnopqrstuvwxyz+/"
sGUID = UCase( sGUID )
For lAt = 1 To 32 Step 3
sBlock = Mid(sGUID, lAt, 3)
lBlock = CLng("&h" & sBlock)
hi = 0
lo = lBlock
While lo > 63
hi = hi + 1
lo = lo - 64
Wend
sBuild = sBuild & Mid(ksB64, lo + 1, 1) _
& Mid(ksB64, hi + 1, 1)
Next
NewHuid = sBuild
End Function
'// ========================================================
You could probably get by with changing the last two characters to
make the number both web accessible and filename tolerant. Use "-"
and "_" maybe? (I avoid these because they wrap and look funny in a
link, respectively.)
Thanks for the laugh,
Shawn K. Hall
http://12PointDesign.com/
http://ReliableAnswers.com/
'// ========================================================
Vegetarians eat vegetables. Beware of humanitarians!
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [email protected]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/active-server-pages/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/