In a translate – can i check if contains alpha char do

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf In a translate – can i check if contains alpha char do

  • Creator
    Topic
  • #54981
    Matthew Taylor
    Participant

      Some of our rooms lead with alpha characters.  What is the simplest way to check for alpha and if yes trim it off?  Example – in a translate i can do an   If 0(0).PV1(0).#3(0).[1]  ct =A  do Y action, but how would i check to see if it contains any value from [A-Z]?  Then if does, then do something?  Like get rid of the alpha character?

    Viewing 4 reply threads
    • Author
      Replies
      • #83669
        Jim Kosloskey
        Participant

          You will need some Tcl.

          string trimleft $var {[A-Z]} should work if the first character is always upper case.

          If it is mixed case you may need to do a case change on the value (in this example the value from XlateInVals is placed in a variable named var – use your own variable name if you like).

          Remember the Xlate In and Out variables are Tcl Lists and need to be treated as such.

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

        • #83670
          Charlie Bursell
          Participant

            set var [lindex $xlateInVals 0]

            regsub -all -nocase — {D} $var {} var

            set xlateOutVals

              The above will get rid of anything in the string that is not a number

          • #83671
            Jim Kosloskey
            Participant

              It looks like string trimleft $var {[A-Z][a-z]} might take care of upper and lower case (if you just want to trim off of the left side.

              email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

            • #83672
              Matthew Taylor
              Participant

                Awesome thanks for the reply.  This works.  I guess I was asking if, within the translate, for an IF statement condition, can you check a range of values versus doing something like the below or a preproc:

                0(0).PV1(0).#3(0).[1]  ct =A ||  

                0(0).PV1(0).#3(0).[1]  ct =B ||  

                0(0).PV1(0).#3(0).[1]  ct =C ||  

                0(0).PV1(0).#3(0).[1]  ct =D

                then do something like

                copy 0(0).PV1(0).#3(0).[1] to 0(0).PV1(0).#3(0).[1] using preproc

                set xlateOutVals

                  1 end ]]

                  Or

                  a trimleft like

                  set ex [lindex $xlateInVals 0]

                  set ex [string trimleft $ex Z]

                  set xlateOutVals

                    Or use your examples

                    My question surrounds only the IF portion and the condition statement in the GUI.  Can you check for a range within the IF condition?  Like a ct =[A-Z]?  (something like that to show intent).

                    FYI I ended up using a combination of both of your example for different things.  Thank you.

                1. #83673
                  Jim Kosloskey
                  Participant

                    As far as I know as of this time the IF Action does not support range checking as you describe. Tcl is there to provide such extension.

                    Glad to hear you have it solved.

                    email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

                Viewing 4 reply threads
                • The forum ‘Cloverleaf’ is closed to new topics and replies.