Skip to main content
Kofax

Scripting - Read or Write a Text File

Article # 3035886 - Page views: 225

Issue

How can be a text file read or write in script?

How to read text from a file or write text to it?

 

Solution

Use the scripts below to read from and write to a text file.

Reading text:
Private Function ReadLineFromFile(Filename As String) As String
   Dim TextLine As String
   ' check if file exists
   If Len(Dir(Filename)) = 0 Then
      ReadLineFromFile = ""
      Exit Function
   End If
   Open Filename For Input As #1
   Line Input #1, TextLine
   Close #1
   ReadLineFromFile = TextLine
End Function
Writing text:
Private Sub WriteLineToFile(Filename As String, Line As String)
   Open Filename For Output As #1
   Print #1, Line
   Close #1
End Sub 

If you look for a sample script to log details in your code then check this link: Scripting - Sample on writing a log file

 

Level of Complexity 

Easy

 

Applies to  

Product Version Build Environment Hardware
Kofax Transformation Modules All      

 

References

Add any references to other internal or external articles

 

 

Article # 3035886
  • Was this article helpful?