Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture script that advances date every 24 hours

Status
Not open for further replies.

djspider74

Technical User
Sep 5, 2002
3
US
Hello,

I put together this script that I thought would work to create a capture file and advance the name of the file along with the date. The problem is that the name of the file doesnt advance with the date. It is almost like the $DATE isnt updating when the loop gets to it again. Is there a way to reset the system variables when the loop runs again? Here is what I have so far. Thanks!!!

proc main

string FileName
string Conn
string TimeStr
integer Position = 1

#define TRUE 1

while TRUE
FileName = $DATE ;sets the name from Control Panel
Conn = $DIALCONNECT
while (Position != 0)
strfind FileName "/" Position ;searches for / (illegal character)
if failure ;tests for a failure
Position = 0 ;sets condition to False
else ;successful search
strdelete FileName Position 1 ;removes illegal character
endif
endwhile
while (Position != 0)
strfind FileName "-" Position ;searches for -(illegal character)
if failure ;tests for a failure
Position = 0 ;sets condition to False
else
strdelete FileName Position 1 ;removes illegal character
endif
endwhile
strcat FileName Conn
strcat FileName ".log"
set capture file FileName ;sets the capture filename
capture on
TimeStr = "23:59:59"
waituntil TimeStr
capture off
pause 2
endwhile

endproc
 
What I have done in the past is use when $DATE to detect when the date has changed from one day to the past. If you use this, you can then call a procedure that recreates the capture file name. Somewhere at the beginning of your script, you would have the line:

when $DATE call create_cap_file

You would then have a corresponding procedure called create_cap_file. In that procedure, you would then have your logic to create the name of the capture file. Since the date has rolled over, it would be created with the new date. You will need to make the name of your capture file a global variable by placing it before proc main so that the created_cap_file procedure can modify the value.
aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top