How can I read/write TXT files with E3?
Solution:
To do so, you must use the methods from FileSystemObject object.
Examples:
** Script to create a TXT file **
Dim aux, aux1
Set aux = CreateObject(“Scripting.FileSystemObject”)
Set aux1 = aux.CreateTextFile(“C:\Temp\Test.txt”, True)
aux1.Close
** Script to add text to the file **
Dim aux, aux1
Set aux = CreateObject(“Scripting.FileSystemObject”)
Set aux1 = aux.OpenTextFile(“C:\Temp\Test.txt”,8)
aux1.WriteLine ” Adds text to the file ”
aux1.Close
** Script to delete data from the file **
Dim aux, aux1
Set aux = CreateObject(“Scripting.FileSystemObject”)
Set aux1 = aux.OpenTextFile(“C:\Temp\Test.txt”,2)
aux1.Write ” ”
aux1.Close
** Script to delete the text file **
Dim aux
Set aux = CreateObject(“Scripting.FileSystemObject”)
aux.DeleteFile(“C:\Temp\Test.txt”)
** Script to read data from the TXT file and load it into InternalTag1 **
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set f = fso.OpenTextFile(“C:\TEMP\Test.txt”, ForReading)
Application.GetObject(“Dados.InternalTag1”).Value = f.ReadAll
NOTE: Attached to this article is a sample application demonstrating the methods seen above.