130 lines
4.0 KiB
Markdown
130 lines
4.0 KiB
Markdown
|
|
||
|
```vb
|
||
|
Sub LoadRecipes()
|
||
|
'Tip:
|
||
|
' 1. Use the <CTRL+SPACE> or <CTRL+I> shortcut to open a list of all objects and functions
|
||
|
' 2. Write the code using the HMI Runtime object.
|
||
|
' Example: HmiRuntime.Screens("Screen_1").
|
||
|
' 3. Use the <CTRL+J> shortcut to create an object reference.
|
||
|
'Write the code as of this position:
|
||
|
|
||
|
|
||
|
' v 0.2 MVera 14-06-24
|
||
|
' This script works with the PC and WinCE filesystem
|
||
|
' Need to change the TypeOfPanel constant
|
||
|
|
||
|
|
||
|
'Define variable of script
|
||
|
Dim FolderPath, fileObj, fileSysObj, Row
|
||
|
Dim n, TagNomeSetDati, Spaces
|
||
|
|
||
|
'Definitions
|
||
|
Const MaxNumDeRiccete = 50
|
||
|
Const MaxNumArea = 2
|
||
|
Const TypeOfPanel = "WindowsPC" ' "WinCE" "WindowsPC"
|
||
|
|
||
|
Dim NumDataSet
|
||
|
|
||
|
'Define Folder Address
|
||
|
On Error Resume Next
|
||
|
|
||
|
If TypeOfPanel = "WinCE" Then
|
||
|
|
||
|
'********************************
|
||
|
' WINCE
|
||
|
'********************************
|
||
|
FolderPath = "\Storage Card SD\AllRecipes"
|
||
|
Set fileSysObj = CreateObject("FileCtl.FileSystem")
|
||
|
If Err.Number <> 0 Then
|
||
|
ShowSystemAlarm "1. " & Err.Number & " " & Err.Description
|
||
|
Err.Clear
|
||
|
End If
|
||
|
|
||
|
If fileSysObj.Dir(FolderPath)="" Then
|
||
|
fileSysObj.MkDir(FolderPath)
|
||
|
If Err.Number <> 0 Then
|
||
|
ShowSystemAlarm "2. " & Err.Number & " " & Err.Description
|
||
|
Err.Clear
|
||
|
End If
|
||
|
End If
|
||
|
|
||
|
fileSysObj = Nothing
|
||
|
Err.Clear
|
||
|
|
||
|
For n = 1 To MaxNumDeRiccete
|
||
|
For NumDataSet = 1 To MaxNumArea
|
||
|
|
||
|
SmartTags("XData\Rcp\File") = FolderPath & "\RECIPE_" & CStr(n) & "_" & CStr(NumDataSet) & ".cvs"
|
||
|
ImportDataRecords SmartTags("XData\Rcp\File"), NumDataSet, hmiOverwriteWithConfirmation, hmiOn, "XData\Rcp\STATUS_NomeSetDati"
|
||
|
|
||
|
'Attendo il Risultato del Formato n
|
||
|
Do Until (SmartTags("XData\Rcp\STATUS_NomeSetDati") = 4 Or (SmartTags("XData\Rcp\STATUS_NomeSetDati")) = 12)
|
||
|
Loop
|
||
|
|
||
|
If (NumDataSet = 1) Then ' The Format Name it is taken from the first Area
|
||
|
'Prendo il Nome del formato n
|
||
|
LoadDataRecord n, NumDataSet, "XData\Rcp\STATUS_NomeSetDati"
|
||
|
|
||
|
'Attendo il Risultato del Formato n
|
||
|
Do Until (SmartTags("XData\Rcp\STATUS_NomeSetDati") = 4 Or (SmartTags("XData\Rcp\STATUS_NomeSetDati")) = 12)
|
||
|
Loop
|
||
|
'Set the Format Name
|
||
|
SmartTags("DB FormatPar_sName_" & CStr(n)) = SmartTags("DB FormatPar_sName")
|
||
|
End If
|
||
|
|
||
|
If Err.Number = 0 Then
|
||
|
ShowSystemAlarm (SmartTags("XData\Rcp\NomeSetDati") & " format upload.")
|
||
|
Else
|
||
|
ShowSystemAlarm "62 " & Err.Number & " " & Err.Description
|
||
|
End If
|
||
|
|
||
|
Next
|
||
|
Next
|
||
|
|
||
|
|
||
|
|
||
|
Else
|
||
|
'********************************
|
||
|
' WINDOWS PC
|
||
|
'********************************
|
||
|
|
||
|
FolderPath = "C:\FLASH\Recipes"
|
||
|
Set fileSysObj = CreateObject("Scripting.FileSystemObject")
|
||
|
|
||
|
If Not fileSysObj.FolderExists(FolderPath) Then
|
||
|
fileSysObj.CreateFolder FolderPath
|
||
|
End If
|
||
|
|
||
|
For n = 1 To MaxNumDeRiccete
|
||
|
For NumDataSet = 1 To MaxNumArea
|
||
|
|
||
|
SmartTags("XData\Rcp\File") = FolderPath & "\RECIPE_" & CStr(n) & "_" & CStr(NumDataSet) & ".cvs"
|
||
|
ImportDataRecords SmartTags("XData\Rcp\File"), NumDataSet, hmiOverwriteWithConfirmation, hmiOn, "XData\Rcp\STATUS_NomeSetDati"
|
||
|
|
||
|
'Attendo il Risultato del Formato n
|
||
|
Do Until (SmartTags("XData\Rcp\STATUS_NomeSetDati") = 4 Or (SmartTags("XData\Rcp\STATUS_NomeSetDati")) = 12)
|
||
|
Loop
|
||
|
|
||
|
If (NumDataSet = 1) Then ' The Format Name it is taken from the first Area
|
||
|
'Prendo il Nome del formato n
|
||
|
LoadDataRecord n, NumDataSet, "XData\Rcp\STATUS_NomeSetDati"
|
||
|
|
||
|
'Attendo il Risultato del Formato n
|
||
|
Do Until (SmartTags("XData\Rcp\STATUS_NomeSetDati") = 4 Or (SmartTags("XData\Rcp\STATUS_NomeSetDati")) = 12)
|
||
|
Loop
|
||
|
'Set the Format Name
|
||
|
SmartTags("DB FormatPar_sName_" & CStr(n)) = SmartTags("DB FormatPar_sName")
|
||
|
End If
|
||
|
|
||
|
If Err.Number = 0 Then
|
||
|
ShowSystemAlarm (SmartTags("XData\Rcp\NomeSetDati") & " format upload.")
|
||
|
Else
|
||
|
ShowSystemAlarm "62 " & Err.Number & " " & Err.Description
|
||
|
End If
|
||
|
|
||
|
Next
|
||
|
Next
|
||
|
|
||
|
End If
|
||
|
End Sub
|
||
|
```
|