ディスクから ASCII ファイルを編集するために使用される 4GL ステートメントはありますか?
6690 次
5 に答える
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.
于 2009-08-28T20:31:47.033 に答える
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.
于 2009-08-24T18:01:26.730 に答える
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.
編集したらファイルを保存することができます;-)
于 2013-08-30T14:26:29.550 に答える
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".
于 2013-08-21T06:03:02.327 に答える