No announcement yet.

Replacement Strings in own script

  • Filter
  • Time
  • Show
Clear All
new posts

    Replacement Strings in own script

    Hello All,

    Does anyone have an example of their own replacement strings script they would be able to share. In my example i have a range of pager messages which have four letter codes at the end which signify which brigades are turning out, what i would like to do is be able to have a list (within the script) so i can feed into the script the devicestring (e2 for example) it would then look for any four letter code with a C in front of it, compare that to the list within the script, and output the full name.

    For example:

    @@ALERT Fxxxxxxxxx TOOM1 STRUC1 HOUSE FIRE x address ST Suburb /Cross St 1 ST //Cross St 2 ST SVSE 8560 J5 (357750) CTOOM CPKHM [NEWB]

    In the example above, it would search and find CTOOM, and CPKHM which would mean the four letter codes are CTOOM, and CPKHM, within the script there would be something like below:

    TOOM: Toomuc
    PKHM: Pakenham
    OFFI: Officer
    BEUP: Beaconsfield Upper
    NAWE: Narre Warren East
    CLEM: Clematis

    And the script would output for the above example Toomuc, Pakenham. The thing that makes things a little tricky is that sometimes there might be only one code CTOOM, or other times there could be lots (up to say 10), but they are always between the (xxxxxx) and [xxxx] points.

    Thanks for suggestions, and or help
    HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

    Facebook | Twitter | Flickr | Google+ | Website | YouTube

    Sub Main(ByVal Parms As Object)
    Dim DStr As String = "@@ALERT Fxxxxxxxxx TOOM1 STRUC1 HOUSE FIRE x address ST Suburb /Cross St 1 ST //Cross St 2 ST SVSE 8560 J5 (357750) 
    Dim Turnout() As String
    Dim subStr As String = ""
    subStr = Trim(DStr.substring(Instr(DStr, ")") + 1, Instr(DStr, "[") - Instr(DStr, ")") - 2))
    'hs.writelog("", subStr)
    Turnout = Split(subStr, Chr(32))
    For i as integer = 0 to ubound(Turnout)
    'hs.writelog("", Turnout(i))
    hs.writelog("", "Turning Out: " & AppList(Turnout(i)))
    End Sub
    Function AppList(ByVal ID As String) As String
    Dim Result As String = ""
    Select Case ID.ToUpper
    Case "CTOOM"
    Result = "Toomuc"
    Case "CPKHM"
    Result = "Pakenham"
    Case "COFFI"
    Result = "Officer"
    Case "CBEUP"
    Result = "Beaconsfield Upper"
    Case "CNAWE"
    Result = "Narre Warren East"
    Case "CCLEM"
    Result = "Clematis"
    Case Else
    Result = "Unknown"
    End Select
    Return Result
    End Function
    Possibly something like this, do your testing though as it is reliant on finding the string between ) and [ which could lead to problems if by chance you have an address with () in or something. It will probably still work but just return lots of unknown messages, there might be a better way of doing this I don't know. You will need to replace the top line with hs.devicestring("e2").


      Check which I posted a while back.