tags:

views:

469

answers:

3

Is there any 4GL statement used for editing an ASCII files from the disk, if so how?

+1  A: 

Yes there is. You can use a STREAM to do so.

/* Define a new named stream */
DEF STREAM myStream.

/* Define the output location of the stream */
OUTPUT STREAM myStream TO VALUE("c:\text.txt").

/* Write some text into the file */
PUT STREAM myStream UNFORMATTED "Does this work?".

/* Close the stream now that we're done with it */
OUTPUT STREAM myStream CLOSE.
Mat Nadrofsky
STREAM is just a keyword for naming a file descriptor. It doesn't "edit" anything per se.
Tom Bascom
+1  A: 

Editing involves reading a file, probably using IMPORT, then manipulating the text using string functions like REPLACE() and finally writing the result probably using PUT. Something like this:

define stream inFile.
define stream outFile.

define variable txtLine as character no-undo.

input stream inFile from "input.txt".
output stream outFile to "output.txt".

repeat:

  import stream inFile unformatted txtLine.

  txtLine = replace( txtLine, "abc", "123" ).   /* edit something */

  put stream outFile unformatted txtLine skip.

end.

input stream inFile close.
output stream outFile close.
Tom Bascom
A: 

Progress could call operating system editor:

OS-COMMAND("vi /tmp/yoyo.txt").

Kevin Rettig