Checking field length in an xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Checking field length in an xlate

  • Creator
    Topic
  • #52038
    Steve Drozdowski
    Participant

      Hello, I need to check the length of a field (PID-7 DOB in this case) in an xlate and take some action if the field length is less than 8 chars.

      I have tried grabbing the field length using some tcl fragment code and saving into a temp var, and then doing a numeric compare to see if the result in less than 8…

      Here is the fragment code (input is PID-7, output is @string_length):

      set xlateOutVals

        ]]

        Here is the IF statement:

        IF @string_length < =8 The IF always evaluates to false.  Does anyone know why?  If I hard-code the value of @string_length to something less than 8, then it will work. Thanks, Steve

      Viewing 4 reply threads
      • Author
        Replies
        • #72830
          Jim Kosloskey
          Participant

            Steve,

            I think you need to do the string Operator lt (has to do with temp variables being strings and the way the IF does its comapres).

            Have you tried the string Operator?

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

          • #72831
            Steve Drozdowski
            Participant

              Hi Jim, I have tried that, however it will not work in the case where PID-7 has a length of, say 14…

              Doing a string compare of 14 lt 8 is true…  Which is not what I want.

              I have tried doing zero-padding prior to the string compare, which does work…  14 lt 08.

              I was just trying to figure out why numeric compare won’t work.

              Thanks.

            • #72832
              Jim Kosloskey
              Participant

                Steve,

                Cloverleaf 5.6.

                When I use a temp variable for both sides of the expression the numeric Operators seem to work.

                I can’t claim to know the whys but that is what I observed.

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

              • #72833
                Steve Drozdowski
                Participant

                  Thanks again Jim…  We just upgraded to 5.7, maybe that is part of the issue?

                • #72834
                  Mike Campbell
                  Participant

                    Steve, here is some tcl code we use to check the length of the SSN, pad with zeros and add the dashes…

                    set in_length [clength $xlateInVals]

                    #

                    if {[lindex $xlateInVals 0] != “”} {set ssn_in

                      ]]}

                      echo Length in of ssn is $in_length

                      regsub {(d{3})(d{2})(d{4})} [lindex $ssn_in 0] {1-2-3} ssn

                      set xlateOutVals

                        This could be used for the MRN.  Just set the format “%08s” to pad with zeros to a length of 8.  

                        We are using this on 5.7

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