wrong # args

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf wrong # args

  • Creator
    Topic
  • #49398
    Rick Pritchett
    Participant

      should i be using some string command in the while instead

      errorInfo:

      wrong # args: should be “while test command”

    Viewing 3 reply threads
    • Author
      Replies
      • #61781
        Jim Kosloskey
        Participant

          Rickie,

          I do this:

          while {$whatever != “”} {

                    other tcl stuff

                  }

          Rather than :

          while {$whatever != “”}

                 { other tcl stuff

                 }

          I think the while command needs to see the open curly brace for the scrit to be executed on the same line as the while command.

          Jim Kosloskey

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

        • #61782
          Charlie Bursell
          Participant

            Jim:

            Please don’t tell these guys to use a numerical compare when comparing strings.  I know it’s hard to teach an old dog like you new tricks but I think there is hope for the others  😆

            It is *MUCH* more ergonomic, and might avoid conversion problems, to use the string command like:

               if {[string equal $var “”]}

            Or even better since an empty list and an empty string are the same:

               if {[lempty $var]}

            You can get by with this most of the time in Tcl but it is slower.  However, if you get used to doing it that way then enter something like !- =foo in Xlate, it will not work.  So it is best to use string commands for string compares and numerical compares for numbers.

            Finished with my  soapbox now  😉

          • #61783
            Jim Kosloskey
            Participant

              Charlie,

              I agree with you regarding using string functions and I tend to use them.

              However, in this case I was trying to show the structural error of the placement of the curly braces (and how that might be corrected) not address the issue of trying to correct the compare technique.

              Jim Kosloskey

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

            • #61784
              Charlie Bursell
              Participant

                Just pulling your string Jim  🙂

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