need tcl code to check multiple fields for value

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf need tcl code to check multiple fields for value

  • Creator
    Topic
  • #48146
    Jason Bond
    Participant

      I need a tcl proc that will check two seperate fields for one of several possible values and kill the message if neither one contains a valid entry.  Checking one field is easy, but I need it to look at two and kill only if both contain invalid entries.  Any help would be most appreciated,  thank you.

      Jason Bond

      Samaritan Health

    Viewing 1 reply thread
    • Author
      Replies
      • #57821
        Jonathan Hamilton
        Participant

          Look up both field values then do a compound if statement.

          if {[cequal $field1 “bad value”] && [cequal $field2 “other bad value”]} {

             lappend dispList “KILL $mh”

          } else {

             lappend dispList “CONTINUE $mh”

          }

          If you have multiple text comparisons you may need to use switch to keep it managable.

          switch -exact — $field1 {

             bad_value1 – bad_value2 – bad_value3 {set field1Trigger 1}

             default {set field1Trigger 0}

          }

          switch -exact — $field2 {

             bad_value5 – bad_value6 {set field2Trigger 1}

             default {set field2Trigger 0}

          }

          if {$field1Trigger && $field2Trigger} {

             lappend dispList “KILL $mh”

          } else {

             lappend dispList “CONTINUE $mh”

          }

          Hope that is what you’re looking for.

          Jonathan

        • #57822
          Charlie Bursell
          Participant

            The code suggestion is good but for ergonomic reasons, I am trying to convince people to waen themselves off of the extended Tcl (TCLX) c commands like cequal, csubstr, cindex, etc.  The string commands are *MUCH* more optimized and will run several orders of magnitude faster if tou are running any Cloverleaf 3.8.1 or greater.

            Just a suggestion.  I know I still have to remind myself.

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