Need help with Regsub trying to change ‘~*’ to a ‘~’.

Clovertech Forums Cloverleaf Need help with Regsub trying to change ‘~*’ to a ‘~’.

  • Creator
    Topic
  • #119303
    Tom Gilbert
    Participant

      Need help with regsub trying to change ‘~*’ (tilde, asterick) to a ‘~’ (tilde).  I am trying to do this in post processing via tcl.

      This is a fixed length file that is coming into cloverleaf and I map it to a variable length and goes outbound.  I then want to you tcl to replace the characters described above.

      The second part of the question is how do you pull the file into the tcl proc.  I have done many times with HL7, is there any difference.

      Thank you in advance for your help and please let me know if I need to give more clarification.

      Thanks,

      Tom Gilbert

    Viewing 3 reply threads
    • Author
      Replies
      • #119304
        Mahmoud Ihaddadene
        Participant

          Hi Tom,

          Here is a example:

          tcl>set a “~*”
          ~*
          tcl>regsub -all — {\*} $a “”

          You can add the following script hciregsub.tcl on outbound TPS with arg {\*} “”

          Hope it will help you

          Regards

          Attachments:
          You must be logged in to view attached files.
        • #119306
          James Nelson
          Participant

            ‘string map’ also works well.

            set OrigString {abcdefg~*hijklmnop}
            set NewVar [string map

              $OrigString]

            1. #119307
              Charlie Bursell
              Participant

                Tom:
                Not sure I understand what you need with the statement:
                “The second part of the question is how do you pull the file into the tcl proc. I have done many times with HL7, is there any difference.”

                You say you are mapping to variable length. Is that done in Tcl? Put the code in the same proc. If not simply add an IB proc either before or after the mapping and put the code there.
                There is no difference in handling HL7 and other forms of files.

                IMHO, string map is a much better alternative in this case than regsub. regsub is nice when you need to pick and choose what needs changing but string map is much more ergonomic when changing all.

                Remember, string map takes a list as the argument to change.
                set Y “HELLO ~* THERE”
                set X [string map

                  $Y]
                  echo $X -> HELLO ~ THERE

                  You can form the list simply by building a space delimited field like “~* ~” but be careful when building lists like this.

                1. #119308
                  Tom Gilbert
                  Participant

                    I got this to work with your help…:)  Here is the regsub I used and it is working…:)

                    regsub -all {~\*} $msg “~” msg

                    Also, this is what I have under ‘Run’

                    # ‘run’ mode always has a MSGID; fetch and process it
                    keylget args MSGID mh
                    keylget args ARGS newchar
                    set st 0
                    if { [llength $newchar] == 3 } { set st [lindex $newchar 2] }
                    set msg [msgget $mh]
                    regsub -all {~\*} $msg “~” msg
                    msgset $mh $msg
                    lappend dispList “CONTINUE $mh”

                    Thank you again…:)

                    Tom Gilbert

                Viewing 3 reply threads
                • You must be logged in to reply to this topic.