Padding records to a specified length

Padding records to a specified length

161
Basic UserBasic User
161

    Jun 17, 2005#1

    I'm kind of new at this. I have used UE for a few years, but never used the macro portion.

    Anyhow, what I am wanting to do is build a macro that will pad variable length records to a lenght of 280 characters. The only catch is that between groups of records there is a line that only has a hex "0a". I need those records to stay as is.

    Any suggestions?

    Bruce

    6,675585
    Grand MasterGrand Master
    6,675585

      Jun 18, 2005#2

      An example how it looks like before and after would help us a lot.
      Best regards from an UC/UE/UES for Windows user from Austria

      161
      Basic UserBasic User
      161

        Jun 20, 2005#3

        Thanks, I'll get a file for you to look at. Give me a bit.

          Jun 20, 2005#4

          BEFORE:

          #999XXXX XXXX XXXX XX XXXX 99999999 9999 99999
          XX99999999999999 XXXX99999999XX 99999999XXXXXXXXXXXXXXXXXXXXXXXXXX 99999 99 XXX9999999XXXX
          XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX99XXXXXX9999X X XXXXXXXXXXXXXXXXXXXXXXX 9999999999
          XXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX 99 XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX99999
          XXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX 99 XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX99999
          XXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX 99 XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX99999
          #999 99999 9


          AFTER:

          #999XXXX XXXX XXXX XX XXXX 99999999 9999 99999
          XX99999999999999 XXXX99999999XX 99999999XXXXXXXXXXXXXXXXXXXXXXXXXX 99999 99 XXX9999999XXXX
          XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX99XXXXXX9999X X XXXXXXXXXXXXXXXXXXXXXXX 9999999999
          XXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX 99 XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX99999
          XXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX 99 XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX99999
          XXXXXXXXX XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX 99 XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX99999
          #999 99999 9
          HOPE THIS HELPS AND THANKS AGAIN.

          6,675585
          Grand MasterGrand Master
          6,675585

            Jun 21, 2005#5

            The example is not very usefull, because BEFORE and AFTER are identical.

            Set your examples inside the

            Code: Select all

             
            tags and use the preview button to first look, if it is correct displayed by the browser.
            Best regards from an UC/UE/UES for Windows user from Austria

            161
            Basic UserBasic User
            161

              Jun 22, 2005#6

              Sorry about that. I didn't realize that it cut all of the spaces out of it basically. Also, there is 1 CRLF at the end of each file. That needs to be there in order for our system to work properly. That can not be padded out, otherwise, to will be seen as a blank record.

              Thanks again for your help.

              The following is the unpadded (original) format.

              Code: Select all

              #999XXXX XXXX XXXX XX XXXX 99999999 9999 99999
              XX99999999999999         XXXX99999999XX                                                                                                     99999999XXXXXXXXXXXXXXXXXXXXXXXXXX    99999 99     XXX9999999XXXX
              XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX99XXXXXX9999X                      X XXXXXXXXXXXXXXXXXXXXXXX     9999999
              XXXXXXXXX XXXXXXXXXXXXXX          XXXXXXXXXXXXXXXXXXXXXXXXXX    99 XXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXX99999
              XXXXXXXXX XXXXXXXXXXXXXX          XXXXXXXXXXXXXXXXXXXXXXXXXX    99 XXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXX99999
              XXXXXXXXX XXXXXXXXXXXXXX          XXXXXXXXXXXXXXXXXXXXXXXXXX    99 XXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXX99999
              #999 99999     9
              
              

              The following is with the records padded out to 280 characters (which is what I am trying to do).

              Code: Select all

              #999XXXX XXXX XXXX XX XXXX 99999999 9999 99999                                                                                                                                                                                                                                          
              XX99999999999999         XXXX99999999XX                                                                                                     99999999XXXXXXXXXXXXXXXXXXXXXXXXXX    99999 99     XXX9999999XXXX                                                                           
              XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX99XXXXXX9999X                      X XXXXXXXXXXXXXXXXXXXXXXX     9999999999                                                                                                                                                             
              XXXXXXXXX XXXXXXXXXXXXXX          XXXXXXXXXXXXXXXXXXXXXXXXXX    99 XXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXX99999                                                                                                                                                                
              XXXXXXXXX XXXXXXXXXXXXXX          XXXXXXXXXXXXXXXXXXXXXXXXXX    99 XXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXX99999                                                                                                                                                                
              XXXXXXXXX XXXXXXXXXXXXXX          XXXXXXXXXXXXXXXXXXXXXXXXXX    99 XXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXX99999                                                                                                                                                                
              #999 99999     9                                                                                                                                                                                                                                                                        
              
              

              6,675585
              Grand MasterGrand Master
              6,675585

                Jun 22, 2005#7

                OK. So this macro should work for you, but only if there is no line, which has a line length greater than 280!

                It simply selects the whole file in column mode expands the selection to 280 characters, copy it and paste it over the selection. This procedure adds the spaces on every line to get 280 characters per line.

                Then a regular expression is used to shorten all lines, which contain only spaces by removing the spaces <- restores lines previously have only a linefeed 0a.

                If your file has lines with more than 280 characters, an additional line splitter code is needed.

                InsertMode
                ColumnModeOff
                HexOff
                UnixReOff
                Bottom
                "
                "
                Top
                ColumnModeOn
                SelectToBottom
                StartSelect
                Key HOME
                Loop 280
                Key RIGHT ARROW
                EndLoop
                Copy
                Paste
                ColumnModeOff
                EndSelect
                Top
                Find RegExp "%[ ]+$"
                Replace All ""
                Bottom
                DeleteLine
                Top
                Best regards from an UC/UE/UES for Windows user from Austria

                161
                Basic UserBasic User
                161

                  Jun 22, 2005#8

                  WOW! That worked perfectly. Where did you learn how to do that? And that quickly.

                  Thank you so much!