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
2009-08-24 18:01:26
STREAM is just a keyword for naming a file descriptor. It doesn't "edit" anything per se.
Tom Bascom
2009-08-28 20:24:27
+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
2009-08-28 20:31:47
A:
Progress could call operating system editor:
OS-COMMAND("vi /tmp/yoyo.txt").
Kevin Rettig
2009-09-04 17:24:53