Skip to main content
Kofax

Log to a File Using KTM Scripting

17770
3014357

Question / Problem: 

Sample on writing to log file using KTM Scripting

Answer / Solution: 

Below is a sample scripting methods that can be used to write to an external file.

Dim iLogFileNo As Integer

Private Sub OpenLog(Filename As String, s As String)
   iLogFileNo = FreeFile
   Open "C:\Temp\CBC.txt" For Append As #iLogFileNo
   Print #iLogFileNo, ""
   Print #iLogFileNo, CStr(Now) + "   " + s
End Sub

Private Sub Log(s As String)
   Print #iLogFileNo, CStr(Now) + "   " + s
End Sub

Private Sub CloseLog(s As String)
   Print #iLogFileNo, CStr(Now) + "   " + s
   Close #iLogFileNo
End Sub

Private Sub TestLog()
   OpenLog("C:\Temp\Test.txt", "Test START")
   Log("Test")
   CloseLog("Test END")
End Sub

Applies to:  

Product Version Category
KTM 6.3 Scripting
KTM 6.2 Scripting