creating a list of hl7 escaped characters

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf creating a list of hl7 escaped characters

  • Creator
    Topic
  • #53304
    Gary Atkinson
    Participant

      I want to create a list of hl7 escaped characters in a proc I am writing.

      F S T R E

      I can’t seem to get it to work.  suggestions?

    Viewing 5 reply threads
    • Author
      Replies
      • #77213
        Levy Lazarre
        Participant

          Gary,

          Would this work for you?

          Code:



          % set mylist [list  \F\ \S\ \T\ \R\ \E\]

          Then, for example, if you do:

          % lindex $mylist 2
          you get
          T

          That seems to be correct.

        • #77214
          Jim Kosloskey
          Participant

            Gary,

            Here is what I did:

            set stuff

              That gives a list called stuff which when echoed has this:

              \T\ \S\

              That looks wrong however when you extract each element (maybe via lindex) you will get T or S, etc. which is what you want.

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

          • #77215
            Gary Atkinson
            Participant

              Follow up question–>

              how can I get lsearch to work with this list using the whole msg as a string?

              Code:


              set escaped_chars  [list \F\ \S\ \T\ \R\ \E\]
              set chkmsg [crange $msg 9 end]
              if {[lsearch $escaped_chars $chkmsg] == 1} {
               do something here….
              }

              always returns -1 :cry:

            • #77216
              Russ Ross
              Participant

                You alwasy get -1 one because the way lsearch works isn’t how you are trying to use it.

                lsearch doesn’t use the list of escape characters to see if one of them exists in your entire message.

                Instead it is the other way around.

                It is comparing your entire message to see if it matches one of your escape characters, which will never be true.

                Here are some examples to illustrate:

                lsearch {a b c d e} c

                returns 2

                lsearch {a b c d e} “message with c in it”

                returns -1

                lsearch {a b c d e {message with c in it}} “message with c in it”

                returns 5

                Russ Ross
                RussRoss318@gmail.com

              • #77217
                Charlie Bursell
                Participant

                  I don’t really understand what you are trying to do.  I assume you want to know if the message contains escape characters

                  foreach ch $escaped_chars {

                     

                    set loc [lsearch $chkmsg $ch]

                    if {$loc >= 0} }

                            echo Escape charactor $ch located at index $loc

                     }

                  }

                • #77218
                  Gary Atkinson
                  Participant

                    Yep Charlie that what I was attempting to do.  I ended up do an regexp instead.

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