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!

Date on file not working correctly

Status
Not open for further replies.

mromano

MIS
Mar 9, 2001
10
US
The question is in addition to my other post: Capture File that is written every minute withou missing anything.

I have the program working correctly except when creating a new file at the end of the day. I have included my script below. Basically it continues to write to the previous days file Sample below as well. The time stamp is after the Date. The phone system time and the computer time are identical.

Question how can I tweak this script so that it creates a new file at midnight?

SCRIPT:

string fname ;first part of file name
string datefilename ;this is the date part of file name
string fullfilename
string datahold
string datecheck

proc main

dial data "PBX"

set aspect rgetchar 20

call file_setup

while 1
rget datahold 256 forever
strreplace datahold "~" ""
fopen 0 fullfilename append
fputs 0 datahold
fclose 0
call date_check

when datecheck call file_setup

endwhile

endproc

proc file_setup
fname = "syrpbx " ;put the first part of name here leave a space at the end
datefilename = "" ;to ensure string datefilename is empty
call file_date ;calls file_date proc
strcat fname datefilename ;this combines the two string (in this case M1_Log YYYYMMDD)
set capture path "D:\PBX DATA RAW\"
set capture file fname ;sets caputure file to the file named in file_date proc
fullfilename = "D:\PBX DATA RAW\"
strcat fullfilename fname
endproc

proc file_date
integer iDay, iMonth, iYear, iHour, iMin, iSec
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt dateFileName "%d%02d%02d" iYear iMonth iDay
strcat dateFileName ".TXT"
endproc

proc date_check
integer iDay, iMonth, iYear, iHour, iMin, iSec
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt datecheck "%d%02d%02d" iYear iMonth iDay
endproc

SAMPLE DATA:
N 108 00 T001002 T010008 06/12 23:43 00:00:46 A 7110
& 0000 0000 9415551210XXXXXX
N 109 00 T001002 T010008 06/13 00:21 00:01:08 A 7110
& 0000 0000
N 110 00 T001001 2080 06/12 22:57 01:38:58
& 0000 0000 3155556
 
You can use when $DATE to detect when the day changes and call the proper procedure to create a new filename. I would put the line right after proc main since you only want the when command run once, otherwise I have seen strange things happen.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top