|
|
|
| 5 April 2002 | WriteLog2() |
| Author | Howard A. Bullock |
| Action | Writes text to a specified log file with optional TimeStamp. |
| Syntax | WriteLog2 ($file, $text, $timestamp) |
| Parameters | |
| Remarks | This function writes (appends) an optionally time stamped log entry to the file name passed into the function. This function searches for the first unused file handle, opens the file, and writes the entry. The file handle is then closed. When the function is unable to perform its write the error is displayed in a message box. |
| Returns | Nothing |
| Dependencies | None. |
| Examples |
WriteLog2("junk.txt","This is a test")
WriteLog2("c:\data\junk.txt","This is a test",0)
WriteLog2("\\SomeServer\data\junk.txt","This is a test",1)
|
| Source |
FUNCTION WriteLog2 ($file, $text, OPTIONAL $timestamp)
DIM $rc, $file, $text, $fh, $timestamp
$fh=1
$rc=Open ($fh, $file, 5)
WHILE ($rc = -3)
$fh=$fh +1
$rc=Open($fh, $file, 5)
LOOP
SELECT
CASE ($rc = 0)
IF ($timestamp=1)
$timestamp=@date+" "+@time+" - "
ELSE
$timestamp=""
ENDIF
$rc=WriteLine($fh, $timestamp + $text + @crlf)
$rc=Close($fh)
CASE ($rc = -2)
$text="WriteLog2: Invalid file handle ($fh) specified when trying to Open $File."
$rc=MessageBox ($text,"Script Error",48)
CASE ($rc = -1)
$text="WriteLog2: Invalid file name ($file) specified for log file."
$rc=MessageBox ($text,"Script Error",48)
CASE ($rc => 0)
$text="System Error($RC) while attempting to open log file ($File)."
$rc=MessageBox ($text,"Script Error",48)
ENDSELECT
ENDFUNCTION ; - WriteLog2 -
|
|
|
|