SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Unique File Name

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Unique File Name
Author Message
David W.



Joined: 18 May 2000
Posts: 6

Post Unique File Name Reply with quote

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.

Thu May 18, 2000 11:18 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6505

Post Re: Unique File Name Reply with quote

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.

Thu May 18, 2000 11:49 am View user's profile Send private message
David W.



Joined: 18 May 2000
Posts: 6

Post Re: Unique File Name Reply with quote


Thanks for the quick response, I will try it.


Thu May 18, 2000 12:28 pm View user's profile Send private message
David W.



Joined: 18 May 2000
Posts: 6

Post Re: Unique File Name Reply with quote

Narrowing it down, this doesn't work in the script library but DOES work when you put it in a job script.

dim FileNameP1, string, @T"yyyymmddhhmmss"
messagebox(FileNameP1)

When it is in the script library, I get a job failed error Exit Code: -1 It appears to be on the @T syntax.

David W.

: 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

Thu May 18, 2000 12:52 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6505

Post Re: Unique File Name Reply with quote

Sorry, user-defined statements don't process macro-parameters. The workaround for this is to pass value of the macro-parameter as an argument to a user-defined statement.

So change it to

Dim FileName, string
Dim FileNameP1, string, @T"yyyymmddhhmmss"
GetUniqueFileName( FileNameP1, FileName )

Where GetUniqueFileName is the name of your user-defined statement
that should have one argument of string type and return some result as a string

: Narrowing it down, this doesn't work in the script library but DOES work when
: you put it in a job script.

: dim FileNameP1, string, @T"yyyymmddhhmmss"
: messagebox(FileNameP1)

: When it is in the script library, I get a job failed error Exit Code: -1 It
: appears to be on the @T syntax.

: David W.

Thu May 18, 2000 2:26 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.