CR 2CRLF

  • Creator
    Topic
  • #49764
    Kathy Riggle
    Participant

      I’m trying to change carriage return (after segment) to carriage return-line feed. I have a script that partially works. It works fine for between segments. However, since the end of the message already has CR-LF, I am getting CR-CR-LF at the end of each message.

       run {

                 # ‘run’ mode always has a MSGID; fetch and process it

                 keylget args MSGID mh

                 set msg [msgget $mh]

                 # substitute all with

                 regsub -all “r” $msg “rn” msg

                 msgset $mh $msg

                 lappend dispList “CONTINUE $mh”

             }

      Is there a better way to do this?

      Kathy

    Viewing 6 reply threads
    • Author
      Replies
      • #63478
        John Mercogliano
        Participant

          Kathy,

           I had to do something similiar. I was having to ftp a file and the receiving system need n after each segment. I used string map to do that.

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

          What are you doing with the message after you are done.  Is it being ftp’d, sent to another system via tcp/ip..etc

          John Mercogliano
          Sentara Healthcare
          Hampton Roads, VA

        • #63479
          Kathy Riggle
          Participant

            John,

            I put something similar in place as an OB tps. It worked between the segments, but I ended up with an extra CR at the end of each message.

            We do ftp the file to our financial system, where it choked on the extra CR.

            Kathy

          • #63480
            Jim Kosloskey
            Participant

              Kathy,

              I guess you could always add one more string map (or regsub – your preference) to substitute /r/n for /r/r/n after your intitial substitution.

              Jim Kosloskey

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

            • #63481
              Tom Rioux
              Participant

                Hi Kathy,

                I’ve taken your script verbatim and run it through my tester (5.2).  I don’t get the same results you are getting.  When I run it through the tester, it changes the r between the segments to rn and leaves the rn at the end of the message as is.

                One possible solution to your problem may be to simply take the “msg” variable and do a split on it and then do a join right after.

                set segs [split $msg r]

                set new_msg [join $segs rn]

                Maybe Jim can confirm but wouldn’t that only touch the ones between the segments?

                Let me know if you get it working.

                Thanks…Tom

              • #63482
                John Mercogliano
                Participant

                  Kathy,

                   Are you using cloverleafs. FTP protocal? We write it to a file manually in a tps using the puts with the nonewline option as they wanted some really weird formatting other then the newlines for each segments.  We then use a cronjob to ftp the file.  The different protocols add there own delimiters when it writes it out.  I’m suspecting that might be where you are getting it from.  This is assuming that you are using the FTP protocal but try setting your outbound style of the FTP protocal configuration to eof.  The way I read it, it should right the message with no delimiter as it assumes the OS will write the eof to the file.

                  Hope this helps,

                  John

                  John Mercogliano
                  Sentara Healthcare
                  Hampton Roads, VA

                • #63483
                  John Mercogliano
                  Participant

                    I really should proofread more when I have a migraine. 😳

                    John Mercogliano
                    Sentara Healthcare
                    Hampton Roads, VA

                  • #63484
                    Kathy Riggle
                    Participant

                      It is truly embarrassing when you miss the most obvious of answers!  ðŸ˜³

                      My regsub script was working OK — my protocol was wrong. Yep, John, you hit it right. I was adding the nl there, instead of using the eof protocol. DUH!

                      Thanks everybody! 😀

                      Kathy

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