Tcl question

Homepage Clovertech Forums Cloverleaf Tcl question

  • Creator
    Topic
  • #118735
    David Ma
    Participant

    I have a tcl that has more message condition checks as following:

    if  {***} then

    {set mykill = TURE}

    if {XYZ} then {

    set mykill = TURE}

    ……………..

    Is there a way that the first message hits the first IF statement then stop going to check the second or third IF statement and check the second message? It will save some message process time in the engine.

     

Viewing 4 reply threads
  • Author
    Replies
    • #118736
      Boris Perov
      Participant

      if {***} {
      set mykill TURE
      } elseif {XYZ} {
      set mykill TURE
      }

    • #118737
      Alfred Cox
      Participant

      Use an IF- ELSE instead of just IF. Like so:

      if {***} {

      set mykill = TRUE

      } else {

      if {XYZ} then {

      set mykill = TRUE}

      }

    • #118738
      Paul Bishop
      Participant

      Another option if the same field is being checked in all the conditions is to use the switch command.

      switch -exact — $field_to_check {
      “value 1” {action to take}
      “value 2” {action to take}

      default {action to take}
      }

      There are two other options besides -exact: -glob and -regexp.  The “–” marks the end of the options, and the “default” entry is the action taken if no match is made.

      Paul Bishop
      Carle Foundation Hospital
      Urbana, IL

    • #118739
      David Ma
      Participant

      Thanks all!

      I mean if the first IF statement match, then tcl will not check the second ELSE IF statement. the TCL will stop after the first IF statemnet and start checking the second message. something like using if {ABC is ture} then {  lappend dispList “KILL $mh”}

    • #118740
      Charlie Bursell
      Participant

      What Boris gave you above is exactly what you ask for.  If the first if statement evaluates true then the elseif will not be evaluated.  That is the purpose of elseif.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10