Tcl Switch Weirdness

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Tcl Switch Weirdness

  • Creator
    Topic
  • #49206

    Comment with one word outside a block in the switch …

    Code:

    set mode “start”

    switch -exact — $mode {
       start {
           puts “start mode”
           return “”   ;# Nothing specific
       }
           # comment
    }

    … No errors.

    Comment with 2+ words outside a block in the switch …

    Code:

    set mode “start”

    switch -exact — $mode {
       start {
           puts “start mode”
           return “”   ;# Nothing specific
       }
           # a comment
    }

    … generates an error …

    Code:

    extra switch pattern with no body, this may be due to a comment incorrectly placed outside of a switch body – see the “switch” documentation
       while executing
    “switch -exact — $mode {
           start {
               puts “start mode”
               return “”   ;# Nothing specific
           }
               # a comment
    …”
       (file “tmp.tcl” line 3)

    . Can anyone explain what is happening?

    -- Max Drown (Infor)

Viewing 0 reply threads
  • Author
    Replies
    • #61100

      Oh. I see … *blinks*

      Code:

      set mode “#”
      switch -exact $mode {
         1 { # do nothing }
         2 { # do nothing }
         3 { # do nothing }
         # { puts “this is NOT a comment!” }
         default { # do nothing }
      }

      -- Max Drown (Infor)

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