Replacing CRLF with CRLF CRLF

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Replacing CRLF with CRLF CRLF

  • Creator
    Topic
  • #53839
    Mark Carey
    Participant

      Hi, I have a receiving system that needs 2 CRLF instead of the standard 1 between each segment in the message and after the message.  My message looks like this.

      MSH… 0D 0A

      PID… 0D 0A

      FT1… 0D 0A

      I need

      MSH… 0D 0A 0D 0A

      PID… 0D 0A 0D 0A

      FT1… 0D 0A 0D 0A

      I’m trying to add a post translate tcl proc to do this but have been unable to get the right string map command.  Here is what I’m trying based on clovertech searches on this subject but it doesn’t seem to recognize the string to be mapped.  We are on an AIX platform.

      set newmsg [string map  {x0Dx0A x0Dx0Ax0Dx0A} $msg]

      I also tried…

      set newmsg [string map {\r\n \r\n\r\n} $msg]

      Neither seems to modify the message at all in my testing.

      Any help here would be appreciated!

      thanks,

      Mark Carey

      Mayo Clinic Health System

    Viewing 1 reply thread
    • Author
      Replies
      • #79145
        Jim Kosloskey
        Participant

          Mark,

          That command worked fine for me.

          Make sure your $msg variable actually contains the message you want changed.

          Then make sure you check the newmsg variable to see if it is changed.

          If both those are correct, then make sure you are reassociating the newmsg variable with the message handle, etc.

          To aid in seeing if the variables have the desired values, try using this proc to display in a hex dump format:

          proc oth_data2hex {data } {

             set where 0

             set res {}

             while {$where<[string length $data]} {

                 set str [string range $data $where [expr $where+15]]

                 if {![binary scan $str H* t] || $t==””} break

                 regsub -all (….) $t {1 } t4

                 regsub -all (..) $t {1 } t2

                 set asc “”

                 foreach i $t2 {

                     scan $i %2x c

                     append asc [expr {$c>=32 && $c<=127? [format %c $c]: "."}]

                 }

                 lappend res [format “%7.7x: %-42s %s” $where $t4  $asc]

                 incr where 16

             }

             join $res n

          }

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

        • #79146
          Russ Ross
          Participant

            Check out my example post of using tps_regsub_all.tcl proc to do something similar.

                <a href="https://usspvlclovertch2.infor.com/viewtopic.php?t=1663&#8243; class=”bbcode_url”>https://usspvlclovertch2.infor.com/viewtopic.php?t=1663

            I think you can modify the input args to fit you situation.

            Since Jim says your syntax worked for him, your issue might be in one of the surrounding circumstatnces you’re not noticing.

            Using this TPS proc might take care of that hidden circumstance.

            Russ Ross
            RussRoss318@gmail.com

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