replacing a "&" with "and" in a part

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf replacing a "&" with "and" in a part

  • Creator
    Topic
  • #54486
    Hina Siddiqui
    Participant

      Hello everyone,

      I am working on a charges interface and facing some issue replacing “&” character with “and” in FT1 7 field while writing a tcl proc.

      What i am doing is as follows:

      I remove MSH 0  to 7 and get 8 to end of message using a string range function and store it in a variable “temp”. Then i use a replace function and replace “&” with “and” for the entire message. After replacing, the “&” i join the entire message stored in temp with the 1 to 7 characters of MSH in order to get the complete message. This seems to be working now.

      But in future, there can be instances where the message might contain the true delimiter “&” that we dont need to replace with “and” .

      If we have the replacable & in a particular sub field (FT1 7), is there a way that we can get just that particular filed and replace it with desired character keeping the entire message untouched.

      This needs to be done in a tcl proc.

      Thanks in advance. 🙂

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

          inside or outside an Xlate via Tcl?

          In either case you willl need to parse out the fields/components in question.

          If inside an Xlate then of course the parsing is easy, if not in an Xlate then you will need to use various list functions to work your way down to the fields/components and put everythiing back together.

          We do somethiing like that here but we do it in an Xlat with a reusable proc.

          We also sometimes put the code in an Xlate which is chained with other Xlates. The first Xlate does the escaping only and the second Xlate then does the actual work needed to build the outbound message(s)

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

        • #81675
          Charlie Bursell
          Participant

            The easiest, in my opinion, would be a simple pre-proc in the route that replaces the specific field in FT1 while ignoring the rest.

            As Jim said, you could do it in Xlate but you would have to replace the component separator with something other than the & then when finished have code that would set the component separator back to the & character.

            The simple pre-proc would only need a few lines

          • #81676
            Hina Siddiqui
            Participant

              Hey Jim,

              Actually we are finding it difficult to parse it inside the Xlate. This is happening because our field FT1_7 contains value like “cbc & abc” . We need to map the exact string to the outbound. But because out string contains “&” which is a true delimiter, as soon as it passes through the variant, cloverleaf breaks the string value thinking “&” as a delimiter.

              Is there a way to handle this in xlate?

            • #81677
              Jim Kosloskey
              Participant

                Hina,

                I sent you the proc in the past it is called xlt_excape_subcomp.tcl. There is User Doc as well – and there is a TPS proc to use to unescape it if you choose.

                You should have received that 11/21/2014.

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

              • #81678
                Hina Siddiqui
                Participant

                  Yes Yes, I do have that doc saved. I will try using it in an xlate.

                  Thanks so much Jim

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