tcl fragment

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tcl fragment

  • Creator
    Topic
  • #52831
    Sarah Brennan Thies
    Participant

      Friends,

      I’m new . . . below is a tcl fragment on patient home phone number coming in hl7 and going out to a frl.  Sometimes the value out is blank . . . I understand the else portion of the code (building the phone number area code first) but need help understanding the first part of the code.  Any help would be greatly appreciated.  Thanks, Sarah

      set inp [lindex $xlateInVals 0]

      if [cequal [string trimleft $inp 0] “”] {

         set xlateOutVals “”

      } else {

         set one [csubstr $inp 1 3]

         set two [csubstr $inp 5 3]

         set three [csubstr $inp 9 4]

         set xlateOutVals “$one$two$three”

      }

    Viewing 3 reply threads
    • Author
      Replies
      • #75604
        James Cobane
        Participant

          Sarah,

          Here is a brief description of what the first part of the code is doing (denoted as comments #):

          set inp [lindex $xlateInVals 0]

        • #75605
          Charlie Bursell
          Participant

            Left out one thing Jim.  If one two or three happens to have spaces you will get undesired results.  Better to do:

            set xlateOutVals

              Also, if this is new code you are writing I would prefer you use the string command rather than cequal, csubstr, etc.  It is more ergonomic and more portable since string is a core command while the others are part of the TclX library.

              If old code I would not go back and modify though

          • #75606
            James Cobane
            Participant

              Good point, Charlie.  This isn’t code I provided (or wrote) but was merely giving an explanation of what was happening in her existing code.  I probably should have provided some recommendations as well; but, that is what we count on you for! 🙂

              – Jim

            • #75607
              Sarah Brennan Thies
              Participant

                Thanks!  This is very helpful 🙂 Sarah

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