script movicon manipolare file csv o txt
Posted: 26/07/2023, 10:22
Buongiorno,
ho un interfaccia creata su movicon a cui dovrei aggiungere tramite script la possibilità di manipolare un file .csv
il programma gira su un TD410
Sub Main()
Dim fo
Dim mode
Const NEU=0
Const delimiter=";"
Const gap=""
Const path = "\My Documents\log_4.csv"
mode=8
Set fo= CreateObject("FileCtl.Filesystem")
fo.Open path,mode
If fo.LOF = NEU Then
fo.LinePrint("intestazione")
End If
fo.LinePrint("test record")
fo.Close
Set fo = Nothing
End Sub
l'avvio dello script mi genera l'errore seguente:
line 12, offset 0
ActiveX automation: server could not be found
ho testato anche il seguente script:
Sub Main()
Dim filePath As String
Dim contentToWrite As String
filePath = "\My Documents\log_114.csv"
contentToWrite = "prova"
' Apri il file per la scrittura
Open filePath For Output As #1
' Scrivi il contenuto nel file
Print #1, contentToWrite
' Chiudi il file
Close #1
End Sub
in questo secondo caso non ho nessun errore visualizzato, ma il file mi rimane comunque vuoto
ho un interfaccia creata su movicon a cui dovrei aggiungere tramite script la possibilità di manipolare un file .csv
il programma gira su un TD410
Sub Main()
Dim fo
Dim mode
Const NEU=0
Const delimiter=";"
Const gap=""
Const path = "\My Documents\log_4.csv"
mode=8
Set fo= CreateObject("FileCtl.Filesystem")
fo.Open path,mode
If fo.LOF = NEU Then
fo.LinePrint("intestazione")
End If
fo.LinePrint("test record")
fo.Close
Set fo = Nothing
End Sub
l'avvio dello script mi genera l'errore seguente:
line 12, offset 0
ActiveX automation: server could not be found
ho testato anche il seguente script:
Sub Main()
Dim filePath As String
Dim contentToWrite As String
filePath = "\My Documents\log_114.csv"
contentToWrite = "prova"
' Apri il file per la scrittura
Open filePath For Output As #1
' Scrivi il contenuto nel file
Print #1, contentToWrite
' Chiudi il file
Close #1
End Sub
in questo secondo caso non ho nessun errore visualizzato, ma il file mi rimane comunque vuoto