用于编译openge目录中的文件的程序

时间:2015-05-27 08:23:19

标签: file compilation openedge

有人可以帮我写一个程序,必须编译目录中的所有文件并报告错误,如果有的话。我的程序必须获取文件夹下所有文件的列表及其完整路径并将其存储在临时表中,然后它必须遍历临时表并编译文件。

2 个答案:

答案 0 :(得分:2)

下面是一个非常艰难的开始。

在联机帮助(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. 

答案 1 :(得分:0)

由于评论不允许我将其粘贴到其中...使用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.