The first part (datetime) can be made as simple as Dim FileNameP2, string, "@T"yyyymmddhhmmss"" The second part can be implemented as a loop Dim suffix, number Dim TestFileName, string Dim FileFound, boolean, True Set TestFileName, FileNameP2 // incerement suffix LoopWhile FileFound, TRY_NEXT Add suffix, 1, suffix Concat FileNameP2, Suffix, TestFileName FileExists TestFileName, FileFound TRY_NEXT: // return unique name Return TestFileName : Hi, : I am trying to generate a unique file name function in the script library. : The format would be YYYYMMDDHHMMSSRRRRRR where RRRRRR is a sequence number : in case file is already exists. Here is the code. : dim RetValue, string : dim TodayDate, date : dim TodayTime, time : dim RandNum, number, 1.0 : dim TestFileName, string : dim FileNameP1, string : dim FileNameP2, string : dim FileNameP3, string : dim FileNameP4, string, "mail.dat" : dim ttime, string : Today(TodayDate) : Now(TodayTime) : Format(TodayDate, "Yyyymmdd", FileNameP1) : Format(TodayTime, "hhmmSs", FileNameP2) : istime(TodayTime, ttime) // Returns true // : messagebox(ttime) // shows "true" // : messagebox(TodayTime) // shows 11:58:34 // : messagebox(FileNameP2) // shows 000000 // : The format(TodayTime, "hhmmSs", FileNameP2) doesn't seem to be : working on this DateTime variable. Ideas? : Is there a better way to generate unique file names? Thanks. : David w.
|