nikita
nikita

Reputation: 31

How to copy one text file to another text file with changes (editing df files)

I am fairly new to progress 4gl. I am trying to copy the contents of one df file into another file where I want to copy everything except the areas of the df file. this is what I have so far.

define stream mystream.
input from "C:\OpenEdge\WRK\df file\sample.df".
do while true on endkey undo, leave:
output to "C:\OpenEdge\WRK\df file\test1.df".
end.
output close.
display "finished".

I would first like to copy all the contents of the first df file into another df file, but right now I'm getting a blank file. Please let me know where I am going wrong.

Upvotes: 0

Views: 958

Answers (2)

Tom Bascom
Tom Bascom

Reputation: 14020

This is what I do:

grep -v AREA < dbname.df > dbname.df2

If you are stuck with on OS that lacks "grep" or if you just have an urge to do it with 4gl code I'd do something like:

define variable lineIn as character no-undo.

input from "dbname.df".
output to "dbname.df2".

repeat:

  import unformatted lineIn.                    /* read the data a whole line at a time */

  if lineIn begins "  AREA" then next.          /* skip lines that start with "  AREA" */

  put unformatted lineIn skip.                  /* spit the input line back out */
  if lineIn = "" then put unformatted skip(1).  /* yes, this is a weird thing */

end.

Upvotes: 0

Austin
Austin

Reputation: 1255

To copy all the contents of first df file to another df file, use this code:

DEFINE VARIABLE TEXT-STRING AS CHARACTER FORMAT "X(76)".

INPUT FROM "C:\OPENEDGE\WRK\CMD-LOG.DF".

OUTPUT TO "C:\OPENEDGE\WRK\MY.DF".
DO WHILE TRUE ON ENDKEY UNDO, LEAVE:
   IMPORT UNFORMATTED TEXT-STRING.
   MESSAGE TEXT-STRING .
END.

INPUT CLOSE.
OUTPUT CLOSE.

Upvotes: 0

Related Questions