是否有用于编辑ASCII文件的Progress 4GL语句?

时间:2009-08-21 15:53:52

标签: progress-4gl

是否有任何4GL语句用于从磁盘编辑ASCII文件,如果是这样的话?

5 个答案:

答案 0 :(得分:8)

编辑涉及读取文件,可能使用IMPORT,然后使用字符串函数(如REPLACE())操作文本,最后使用PUT编写结果。像这样:

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.

答案 1 :(得分:1)

是的。您可以使用STREAM来执行此操作。

/* 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.

答案 2 :(得分:0)

Progress可以调用操作系统编辑器:

OS-COMMAND(“vi /tmp/yoyo.txt”)。

答案 3 :(得分:0)

您可以使用copy-lob来读取和写入文件

DEF VAR lContents AS LONGCHAR NO-UNDO.

/* read file */
COPY-LOB FROM FILE "ascii.txt" TO lContents.
/* change Contents, e.g. all capital letters */
lContents = CAPS(lContents).
/* save file */
COPY-LOB lContents TO FILE "ascii.txt".

答案 4 :(得分:0)

我认为对于“编辑”你的意思是能够阅读,然后在屏幕上显示文件并操纵文件?

如果是这样,那么你有一个简单的,当然,文件的大小不能大于最大值。 vchar变量的容量:

def var fileline as char format "x(250)".  /* or shorter or longer, up to you*/
def var filedit as char.

/*you have to quote it to obtain & line into teh charvar*/

unix silent quoter kk.txt > kk.quoted.

input from kk.quoted no-echo.


repeat:

   set fileline.

   filedit = filedit + (fileline + chr(13) + chr(10)) .

end.

input close.

update filedit view-as editor size 65 by 10.

当然,您可以设法在编辑后保存文件; - )