Skip to main content

Log to a File Using KTM Scripting

Article # 3014357 - Page views: 416


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")
   CloseLog("Test END")
End Sub

Applies to:  

Product Version Category
KTM 6.3 Scripting
KTM 6.2 Scripting


  • Was this article helpful?