Get files

Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO Windows,Linux

Syntax

Get files (list-name, first-column, path, file-type [,creator-type] [,8.3]) Returns err-code

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This command returns a list of files in a directory or folder.

To list only files of a specified type, specify the file-type, which is a wildcard, such as ‘*.LBS’.

If you omit the file-type, the command returns the names of all the files.

You specify the list with list-name. The list must have a column defined as list-column-name, where list-column-name is the name of a variable. This column will receive the names of the files found under the specified path-name, including the extension.

On Windows, you can also supply the 8.3 parameter. This defaults to kFalse. If you pass kTrue, then Get files returns the 8.3 name equivalent to any long file names.

It returns an error code (See Error Codes), or zero if no error occurs.

When constructing the path to a file or folder, you can use sys(9) to insert the correct path delimiter for the current platform: \ (back-slash) on Windows, or / (forward-slash) for Unix and 64-bit macOS (: colon on 32-bit macOS). In addition, you can use sys(115) to return the full pathname of the folder containing the Omnis executable, including the terminating path separator, which might be useful to reference files in the Omnis tree.

The following example uses Get files to build a list of all the libraries in the folder returned by sys(10).

Example

Do  lFileList.$define(lFileName)
# get the path of the examples folder in the studio tree
Calculate lPathname as con(sys(115),'welcome',sys(9),'examples')
# return the list of all example libraries
Get files (lFileList,lFileName,lPathname,'*.lbs'Returns lErrCode