scripting@wanadoo.nl




WriteLog()

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
6 April 2002 WriteLog()
AuthorHoward A. Bullock
Action Permanently opens the file coded in the UDF as file handle "1" and writes time stamped text to file handle "1" throughout the execution of your script.
SyntaxWriteLog ($text) 
Parameters
  • $text (Required / String) Line of text to be written to the file. 
  • RemarksThis UDF is intended to be the main logging mechanism of the script. It opens file handle "1" the first time it is executed but does not close it. It then writes text to file handle "1" every time it is invoked. Therefore this function should be called at the very beginning of your script so that you are sure to get file handle "1".
    This UDF was designed to be a quick & simple way to have a log file generated. In our environment, a sub-script can be written and maintained by local LAN Admins. This is the common logging UDF that can be easily employed by them to continue logging data to a common file.
    See WriteLog2() if you need to specify multiple log files or for logging requirements that do not require the timestamp. 
    ReturnsNothing 
    DependenciesNone. 
    Examples
    WriteLog("")
    WriteLog("Starting Kixtart script")
    
     
    Source
    FUNCTION WriteLog ($text)
      DIM $rc, $text, $logfile, $filehandle
    
      $filehandle=1
      $logfile="%temp%\logon.log"
      $rc=WriteLine ($filehandle, "@Date @Time - $Text" + Chr(13) + Chr(10))
      IF ($rc < 0)
        $rc=Close($filehandle)
        $rc=Open($filehandle, "$LogFile", 5)
        SELECT
        CASE ($rc = -1)
          $rc=MessageBox("Invalid file name ($LogFile) specified for log file.","Logon Script Error",48)
        CASE ($rc = 0)
          writelog ($text)
        CASE ($rc => 0)
          $rc=MessageBox("Error($RC) while attempting to open log file ($LogFile).","Logon Script Error",48)
        ENDSELECT
      ENDIF
    ENDFUNCTION ; - WriteLog -
     
      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