home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-29 | 3.4 KB | 120 lines | [TEXT/ttxt] |
- proc CalcLogPath
- //
- // Calculate the log path: use the path to the layout (passed through
- // 'it') and append '.log'. This will not work if the layout filename
- // is longer than 27 characters and does not end on .MSL - try to avoid
- // that, or the log might be appended to your layout file instead.
- //
- logPath = it
- if (upper(right(logPath,4)) = ".MSL") then
- logPath = left(logPath,len(logPath) - 4)
- end if
- logPath = logPath + ".log"
- end proc
-
- proc OnOpenLayout
- //
- // Create variables for storing job information. These variables
- // need to be created when the layout is opened. Otherwise, they will
- // be removed from memory before the OnEndJob procedure is called.
- // By creating them when the layout opens, they will remain available
- // after the job is processed, and they will keep whatever value was
- // assigned to them while the job was processed.
- //
- logPath = ""
- jobStartTime = 0
- jobClassName = ""
- //
- // Build table of month names. We use a string as the subscript -
- // month[1] is not the same as month["01"]. Using a string subscript
- // allows us to use MID(somedate,5,2) as the subscript for the month table.
- //
- month["01"] = "Jan"
- month["02"] = "Feb"
- month["03"] = "Mar"
- month["04"] = "Apr"
- month["05"] = "May"
- month["06"] = "Jun"
- month["07"] = "Jul"
- month["08"] = "Aug"
- month["09"] = "Sep"
- month["10"] = "Oct"
- month["11"] = "Nov"
- month["12"] = "Dec"
- call CalcLogPath
- end proc
-
- proc OnSaveLayout
- call CalcLogPath
- end proc
-
- proc OnStartJob
- //
- // The job is about to be read by MarkzONE - store the current time
- // (DATE() returns a 14-character string in YYYYMMDDhhmmss format)
- //
- jobStartTime = DATE()
- end proc
-
- proc OnJobRead
- //
- // The job has been read into memory - store its class name for later
- // reference
- //
- jobClassName = it.class_name
- end proc
-
- proc OnEndJob
- //
- // Error checking
- //
- if logPath is undefined then
- print "Cannot write log - close and re-open layout first"
- return
- end if
- if logPath = "" then
- print "Cannot write log - save layout first"
- return
- end if
- //
- // Job has been processed and removed from memory. 'it' is the path
- // of the job after processing. Calculate the time elapsed, and
- // write it to the log file. Separate fields by TAB (CHR(9)) characters
- // so it is easy to read the log file into a spreadsheet program.
- // DATE_SECONDS returns a floating point value which corresponds
- // to the number of seconds between "19700101000000" and the
- // date string provided. Subtracting the two date values gives
- // us the number of seconds elapsed.
- //
- jobPath = it
- timeTaken = DATE_SECONDS(DATE()) - DATE_SECONDS(jobStartTime)
- //
- // Format the date nicely in now. Use the table of month names
- //
- now = DATE()
- dateNow =
- MID(now,7,2) + "/" + month[MID(now,5,2)] + "/" + left(now,4)
- timeNow =
- MID(now,9,2) + ":" + MID(now,11,2) + ":" + RIGHT(now,2)
- //
- // Write to log file in tab text format (Mac) or comma-separated (Win)
- // OS is a system variable.
- //
- if UPPER(OS) = "MAC" then
- write logPath,
- dateNow
- + chr(9) + timeNow
- + chr(9) + jobClassName
- + chr(9) + jobPath
- + chr(9) + timeTaken
- else
- write logPath,
- '"' + dateNow + '"'
- + ',"' + timeNow + '"'
- + ',"' + jobClassName + '"'
- + ',"' + jobPath + '"'
- + ',"' + timeTaken + '"'
- end if
- end proc
-
-