Okay, in an other topic I was searching for saving and fetching data out of a database. I was doing it in a PLC, but it eated all the retentive memory of the CPU.
So the idea is writing to csv and reading from it.
I have 5 correctionparameters that I save and retrieve. I write them on a buttonevent and read them when the productcode changes.
This is the write script:
So I print 5 line's in a csv, the csv is named after the product (artikelnummer). This is done for retrieving easely.
This is the read script:
This one doesn't work...
Any ideas please ?
Thanks is forward.
So the idea is writing to csv and reading from it.
I have 5 correctionparameters that I save and retrieve. I write them on a buttonevent and read them when the productcode changes.
This is the write script:
Code:
Dim f, fs, file_path, file_name, file_name_path
On Error Resume Next
Set fs = CreateObject("filectl.filesystem")
Set f = CreateObject("filectl.file")
file_path= "\Storage Card MMC\"
file_name= CStr(SmartTags("ACTIVE BATCH.ORDER_DATABASE.ARTIKEL_NUMMER"))& ".csv"
file_name_path= file_path & file_name
If Err.Number <> 0 Then
ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
Err.Clear
Exit Sub
End If
f.open (file_name_path), 2
f.Lineprint (SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.ECS") & ";")
f.Lineprint (SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOEK") & ";")
f.Lineprint (SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOOGTE") & ";")
f.Lineprint (SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.ECS") & ";")
f.Lineprint (SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.HOEK") & ";")
f.Close
Set f = Nothing
Set fs = Nothing
If Err.Number <> 0 Then
ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
Err.Clear
Exit Sub
End If
ShowSystemAlarm "Corrections storage was successful"
So I print 5 line's in a csv, the csv is named after the product (artikelnummer). This is done for retrieving easely.
This is the read script:
Code:
Dim f, fs, file_path, file_name, file_name_path, DataSet,MyZf, field, HiField, i, j
On Error Resume Next
Set fs = CreateObject("filectl.filesystem")
Set f = CreateObject("filectl.file")
file_path= "\Storage Card MMC\"
file_name= CStr(SmartTags("ACTIVE BATCH.ORDER_DATABASE.ARTIKEL_NUMMER"))& ".csv"
file_name_path= file_path & file_name
If Err.Number <> 0 Then
ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
Err.Clear
Exit Sub
End If
If fs.dir(file_name_path)="" Then
SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.ECS") = 0
SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOEK") = 0
SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOOGTE") = 0
SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.ECS") = 0
SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.HOEK") = 0
Else
Do While f.eof=False
MyZf=f.lineinputstring
field=Split(MyZf,";")
For i= 0 To 4
field(i)= Replace(field(i),"","")
HiField(j,i)=field(i)
Next
SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.ECS") = HiField(0,1)
SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOEK") = HiField(1,1)
SmartTags("INSTELLING PONSUNIT.CORRECTIES.LINKS.HOOGTE") = HiField(2,1)
SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.ECS") = HiField(3,1)
SmartTags("INSTELLING PONSUNIT.CORRECTIES.RECHTS.HOEK") = HiField(4,1)
j=j+1
Loop
f.close
End If
Set f = Nothing
Set fs = Nothing
If Err.Number <> 0 Then
ShowSystemAlarm "Error#" & CStr(Err.Number)&""& Err.Description
Err.Clear
Exit Sub
End If
ShowSystemAlarm "Corrections fetching was successful"
This one doesn't work...
Any ideas please ?
Thanks is forward.