I've managed to work through the RecipeButton.vb read the recipes from my Recipe.ini file way I want, but now I want to be able to over-write values for recipe changes. It appears in the parser.vb file that this functionality should be there already, but I haven't been able to get my file to change.
Here is the code I've tried so far and while it appears to work (no errors), it doesn't do anything to the file designated in the IniFileName section.
Protected Overrides Sub OnClick(e As EventArgs)
MyBase.OnClick(e)
'* Make sure an INI file was specified
If Not String.IsNullOrEmpty(m_IniFileName) Then
If String.IsNullOrEmpty(RecipeFileError) Then
' Get the file name from the button configuration
Dim file As New AdvancedHMIDrivers.IniParser(m_IniFileName)
' Get the file section from the PLC as per the button configuration
Dim section As String = m_ComComponent.Read(m_PLCAddressSaveSection, 1)(0)
' Verify the file section exists
If Not String.IsNullOrEmpty(section) Then
Dim c() As Char = {vbNullChar}
Dim TrimmedSection As String = section.Trim(c)
Dim SettingList() As String = file.ListSettings(section.Trim(c))
Settings.Clear()
For index = 0 To SettingList.Length - 1
If String.Compare(SettingList(index), "ButtonText", True) <> 0 Then
Dim s As New RecipeSaveSetting(SettingList(index), section)
Settings.Add(s)
Else
Text = file.GetSetting(TrimmedSection, SettingList(index))
End If
Next
End If
If m_ComComponent IsNot Nothing Then
For i = 0 To Settings.Count - 1
Dim v As String
Try
v = ""
v = m_ComComponent.Read(Settings(i).PLCAddress, 1)(0)
While v Is ""
End While
file.DeleteSetting(section, Settings(i).PLCAddress)
file.AddSetting(section, Settings(i).PLCAddress, v)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("Faile to write " & Settings(i).Value & " to " & Settings(i).PLCAddress & " ." & ex.Message)
End Try
Next
Else
System.Windows.Forms.MessageBox.Show("ComComponent Property must be set.")
End If
Else
System.Windows.Forms.MessageBox.Show("INI File Error - " & RecipeFileError)
End If
End If
End Sub
Any help?