scripting@wanadoo.nl




WriteLog2()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
5 April 2002 WriteLog2()
AuthorHoward A. Bullock
Action Writes text to a specified log file with optional TimeStamp.
SyntaxWriteLog2 ($file, $text, $timestamp) 
Parameters
  • $file (Required / String) Valid filename.
  • $text (Required / String) Text to be written to the log file
  • $timestamp (Required / String) [0|1] The default is 0. Use a value of "1" to have your line of text prefixed with a date time stamp. 
  • RemarksThis 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. 
    ReturnsNothing 
    DependenciesNone. 
    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 -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter