Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2013
    Posts
    4

    Unanswered: REXX to insert/delete lines in a sequential file

    Hi,

    I need to write a Rexx script which inserts/deletes lines in a particular way.

    The sequential file would already have some text data in it.

    My requirment is like this.

    1) I need to insert lines just before a string (lets say 'Thanks')
    ex:-
    HI,
    THE FOLLOWING ERRORS ARE FOUND.

    THANKS,
    MR.PROTAGONIST


    So the new lines should be inserted between the strings 'THE FOLLOWING ERRORS ARE FOUND' and 'THANKS,'

    2) When I submit my rexx script for the 2nd time, first these newly inserted lines sholud be deleted and then new set of lines should be inserted.


    Note:
    These new set of lines which are inserted/deleted are not constant in number. The only thing that's constant is the are always inserted before a particular string(here 'THANKS,')


    Thanks in advance

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    Whether you use REXX (if the volume is large, REXX is Not a good choice) or some other language, suggest you:
    Code:
     read the new inserts into a variable/array
    loop
     read the input file copying to the output until "THE FOLLOWING ERRORS . . . " is encountered
     read the inpout file (not copying the records) until "THANKS" is encountered
     write the entries from the variable/array followed by the REWARDS line
    endloop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •