Author Topic: Using MessageDisplayByValue to print Failcode label  (Read 653 times)

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Using MessageDisplayByValue to print Failcode label
« on: October 10, 2018, 04:04:11 PM »
I have a working MessageDisplayByValue1 which uses an inifile 'alarms.txt', the text message is displayed based on PLC value.
Since its lengthy text can not fit the label, I resorted to create another MessageDisplayByValue2
which uses the same PLC value but different inifile 'FailCodes.txt' with much shorter description( see below):

1,M25 LV -
2,M25 HV -
3,M25 LV HV - M24 LV

and some codes to print the fail label:
Code: [Select]
        Dim s As String() = MessageDisplayByValue2.Text.Split("-"c)
        Dim fail1 As String = s(0)
        Dim fail2 As String = s(1)
        ZPL_STRING = ZPL_FAIL       'copy fail label code to ZPL string
        ZPL_STRING = ZPL_STRING.Replace("[FailReason1]", fail1)
        ZPL_STRING = ZPL_STRING.Replace("[FailReason2]", fail2)

        SendZplOverTcp(ZebraAddress)


I'd like to avoid using MessageDisplayByValue2, use only FailCodex.txt and pass the string based on PLC value of MessageDisplayByValue1.
I tried to use KeyValuePair , but have not been able to sort it out yet:

Code: [Select]
Dim lines() As String = System.IO.File.ReadAllLines(".\FailCodes.txt")
Dim list As List(Of KeyValuePair(Of Integer, String)) = New List(Of KeyValuePair(Of Integer, String)
   

Thanks in advance.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Using MessageDisplayByValue to print Failcode label
« Reply #1 on: October 10, 2018, 07:47:23 PM »
What about using a dictionary:
Code: [Select]
        Dim lines() As String = System.IO.File.ReadAllLines(".\FailCodes.txt")
        Dim ItemList As New Dictionary(Of Integer, String)
        For Each LineItem In lines
            Dim pair() As String = LineItem.Split(","c)
            If pair.Count >= 2 Then
                ItemList.Add(pair(0), pair(1))
            End If
        Next

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Using MessageDisplayByValue to print Failcode label
« Reply #2 on: October 10, 2018, 08:16:12 PM »
You always have better idea! Thanks again, Archie.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================