Tcl help: how do I identify a number?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Tcl help: how do I identify a number?

  • Creator
    Topic
  • #48390
    Rentian Huang
    Participant

      In Tcl, how do I identify that a variable is a number? Or Char?

      similiar to IsNumberic, or IsChar…

      Thanks,

      Sam   8)

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

          Sam,

          Check out ‘string is’.

          Jim Kosloskey

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #58491
          Rentian Huang
          Participant

            Jim,

            I guess I am lost, can you give me more detail of ‘string is’? an example?

            Thanks,

            Sam

          • #58492
            Jim Kosloskey
            Participant

              Sam,

              The string Tcl command has many options. One of them is the ‘is class’ option. Do a help string in hcitcl to see all options etc.

              example:

              set junk abcdef

              string is digit -strict $junk

               —> returns a zero (not true)

              set stuff 12345

              string is digit -strict $stuff

                —> returns a one (true)

              set nonsense “”

              string is digit -strict $nonsense

                —> returns a zero (not true)

              Jim Kosloskey

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #58493
              Rentian Huang
              Participant

                Jim,

                All the scenarios work except this case:

                set ICD9 401.9

                string is digit -strict $ICD9

                —> returns zero

                I tried the double para and it comes out good.

                string is double $ICD9

                Thanks for your help!!!

                Sam  8)

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