谁能帮我写一个程序,编译目录中的所有文件并报告错误,如果有的话。为此,我的程序必须获得文件夹下所有文件的列表及其完整路径,并将其存储在临时表中,然后它必须循环遍历临时表并编译文件。
下面是一个非常粗糙的开始。
在联机帮助(F1)中查找有关COMPILE语句和COMPILER系统句柄的更多信息。
请注意,编译需要安装开发人员许可证。如果没有它,COMPILE语句将失败。
DEFINE VARIABLE cDir AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO FORMAT "x(30)".
ASSIGN
cDir = "c:temp".
INPUT FROM OS-DIR(cDir).
REPEAT:
IMPORT cFile.
IF cFile MATCHES "*..p" THEN DO:
COMPILE VALUE(cDir + cFile) SAVE NO-ERROR.
IF COMPILER:ERROR THEN DO:
DISPLAY
cFile
COMPILER:GET-MESSAGE(1) FORMAT "x(60)"
WITH FRAME frame1 WIDTH 300 20 DOWN.
END.
END.
END.
INPUT CLOSE.
由于注释不允许我粘贴这么多内容…使用INPUT FROM OS-DIR返回一个目录下的所有文件和目录。您可以使用此信息继续沿着目录树查找所有子目录
OS-DIR documentation:
Sometimes, rather than reading the contents of a file, you want to read a list of the files in a directory. You can use the OS–DIR option of the INPUT FROM statement for this purpose.
Each line read from OS–DIR contains three values:
*The simple (base) name of the file.
*The full pathname of the file.
*A string value containing one or more attribute characters. These characters indicate the type of the file and its status.
Every file has one of the following attribute characters:
*F — Regular file or FIFO pipe
*D — Directory
*S — Special device
*X — Unknown file type
In addition, the attribute string for each file might contain one or more of the following attribute characters:
*H — Hidden file
*L — Symbolic link
*P — Pipe file
The tokens are returned in the standard ABL format that can be read by the IMPORT or SET statements.