XML FIND FILE

This statement has the following parameters:

Parameter Description
DirectoryName Nonnumeric literal or identifier of an alphanumeric data item that specifies the pathname of the directory to check for documents (files ending with .xml or the extension specified in the Extension parameter).
FileName Identifier of an alphanumeric data item that will contain the filename of one document that was found in the specified directory after successful completion of the statement.
[Extension] Optional. Nonnumeric literal or identifier of an alphanumeric data item that specifies a user-defined extension having the format of a leading period followed by the extension name; the extension name may be any length from one to the number of characters permitted by the operating system. If Extension is not specified, the extension .xml is used.

Description

The XML FIND FILE statement looks in the directory specified by the DirectoryName parameter for a document (a file with the .xml extension, unless the Extension parameter is specified). If there are one or more documents in the specified directory with the specified extension, the name of one of the files will be returned in the data item specified by the FileName parameter.

If the statement succeeds (the condition-name XML-IsSuccess is true), the filename in the data item specified by the FileName parameter, when it is an XML document, may be processed by using it in an XML IMPORT FILE statement .

Before calling XML FIND FILE again (to process the next file), you must call XML REMOVE FILE to delete the XML document that was just processed. Otherwise, the next call to the XML FIND FILE statement may return the same file.

A status value is returned in the data item XML-Status of XML-data-group, which is defined in the copy file lixmldef.cpy. The condition-name

XML-IsDirectoryEmpty will be true if the directory is empty.

Example

FIND-DOCUMENT.
    PERFORM WITH TEST AFTER UNTIL 0 > 1
        XML FIND FILE
            "MY-DIRECTORY"
            MY-FILE-NAME
        IF XML-IsSuccess
            EXIT PERFORM
        END-IF
        IF XML-IsDirectoryEmpty
            CALL "C$DELAY" USING 0.1
        END-IF
        IF NOT XML-OK GO TO Z.
    END-PERFORM
*> Process found document