#Source Code Sub Write() 'Starting error routine On Error Resume Next Dim fo, fso, duomenys, i, delim, txtField, TagName, path Set txtField = HmiRuntime.Screens("Write").ScreenItems("txtFieldW") 'Please replace all sequences which are enclosed with '_' by your own code. If SmartTags("Name") = "" Then txtField.Text = txtField.Text & "Standard name is illegal" Set txtField = Nothing Exit Sub Else duomenys = SmartTags("Name") & ";" End If For i = 0 To 4 TagName = "Value" & (i+1) If Err.Number 0 Then txtField.Text = txtField.Text & "Assign tag name: " & Err.Description & vbCrLf Err.Clear Set txtField = Nothing Exit Sub End If If i < 4 Then delim = ";" Else delim = "" End If duomenys = duomenys & SmartTags(TagName) & delim If Err.Number 0 Then txtField.Text = txtField.Text & "Adding data to variable: " & Err.Description & vbCrLf Err.Clear Set txtField = Nothing Exit Sub End If Next txtField.Text = txtfield.Text & duomenys & vbCrLf If Err.Number 0 Then txtField.Text = txtField.Text & "Writing data to text field: " & Err.Description & vbCrLf Err.Clear Set txtField = Nothing Exit Sub End If Set fo = CreateObject("FileCtl.File") Set fso = CreateObject("FileCtl.FileSystem") If Err.Number 0 Then txtField.Text = txtField.Text & "Create file object: " & Err.Description & vbCrLf Err.Clear Set txtField = Nothing Exit Sub End If path = "\flash\Standard\" If fso.dir(path) = "" Then txtField.Text = txtField.Text & "File does not exists" & vbCrLf fso.MkDir(path) End If If Err.Number 0 Then txtField.Text = txtField.Text & "Check for file: " & Err.Description & vbCrLf Err.Clear Set txtField = Nothing Exit Sub End If path = path & "Standartas.txt" 'MODE '8 Apend File opened To Append To it. Default. '32 Binary File opened For Binary access. '1 Input File opened For read access. '2 Output File opened For write access. '4 Random File opened For Random access. fo.open path, 8 If Err.Number 0 Then txtField.Text = txtField.Text & "Error opening file for write: " & Err.Description & vbCrLf Err.Clear Set txtField = Nothing Set fso = Nothing Set fo = Nothing Exit Sub End If fo.lineprint(duomenys) fo.close Set fso = Nothing Set fo = Nothing Set txtField = Nothing End Sub
#Source Code
Sub Write()
'Starting error routine
On Error Resume Next
Dim fo, fso, duomenys, i, delim, txtField, TagName, path
Set txtField = HmiRuntime.Screens("Write").ScreenItems("txtFieldW")
'Please replace all sequences which are enclosed with '_' by your own code.
If SmartTags("Name") = "" Then
txtField.Text = txtField.Text & "Standard name is illegal"
Set txtField = Nothing
Exit Sub
Else
duomenys = SmartTags("Name") & ";"
End If
For i = 0 To 4
TagName = "Value" & (i+1)
If Err.Number 0 Then
txtField.Text = txtField.Text & "Assign tag name: " & Err.Description & vbCrLf
Err.Clear
Set txtField = Nothing
Exit Sub
End If
If i < 4 Then
delim = ";"
Else
delim = ""
End If
duomenys = duomenys & SmartTags(TagName) & delim
If Err.Number 0 Then
txtField.Text = txtField.Text & "Adding data to variable: " & Err.Description & vbCrLf
Err.Clear
Set txtField = Nothing
Exit Sub
End If
Next
txtField.Text = txtfield.Text & duomenys & vbCrLf
If Err.Number 0 Then
txtField.Text = txtField.Text & "Writing data to text field: " & Err.Description & vbCrLf
Err.Clear
Set txtField = Nothing
Exit Sub
End If
Set fo = CreateObject("FileCtl.File")
Set fso = CreateObject("FileCtl.FileSystem")
If Err.Number 0 Then
txtField.Text = txtField.Text & "Create file object: " & Err.Description & vbCrLf
Err.Clear
Set txtField = Nothing
Exit Sub
End If
path = "\flash\Standard\"
If fso.dir(path) = "" Then
txtField.Text = txtField.Text & "File does not exists" & vbCrLf
fso.MkDir(path)
End If
If Err.Number 0 Then
txtField.Text = txtField.Text & "Check for file: " & Err.Description & vbCrLf
Err.Clear
Set txtField = Nothing
Exit Sub
End If
path = path & "Standartas.txt"
'MODE
'8 Apend File opened To Append To it. Default.
'32 Binary File opened For Binary access.
'1 Input File opened For read access.
'2 Output File opened For write access.
'4 Random File opened For Random access.
fo.open path, 8
If Err.Number 0 Then
txtField.Text = txtField.Text & "Error opening file for write: " & Err.Description & vbCrLf
Err.Clear
Set txtField = Nothing
Set fso = Nothing
Set fo = Nothing
Exit Sub
End If
fo.lineprint(duomenys)
fo.close
Set fso = Nothing
Set fo = Nothing
Set txtField = Nothing
End Sub