GDL File Manager I/O Add-On

GDL File Manager I/O

The GDL File Manager In-Out Add-On allows you to scan a folder for the contained files/subfolders from a GDL script.

Specify the folder you would like to scan by using the OPEN command.

Get the first/next file/folder name in the specified folder by using the INPUT command.

Finish folder scanning by using the CLOSE command.

Specifying Folder

channel = OPEN (filter, filename, paramstring)

channel: folder id


filter: the internal name of the Add-On, in this case “FileMan”


filename: the name of folder to be scanned (OS dependent path) – folder id string (in DIALOG mode – see later)


paramstring: Add-on specific parameter. The parameters in paramString must be separated by commas (,).
1. parameter: FILES/FOLDERS: This parameter can be file or folder depending on what you’re searching for.
2. parameter (optional): DIALOG: Indicates that the folder is given by a file id string instead of a file path.
When this is the case, at the first time (and each time when the corresponding file path seems to be invalid) the user will be faced a dialog box to set the id string – file path correspondence, which will be stored.


Opening the root directory of the C drive (on a PC) for file-scanning

folder = OPEN ("FileMan", "c:", "FOLDERS")


Getting File/Folder Name

n = INPUT (channel, recordID, fieldID, var1 [, var2, ...])

channel: folder id (returned by the OPEN command)
recordID: 0 (reserved for further development)
fieldID: 0 (reserved for future development)
var1, ...: variable(s) to receive the file/folder name(s)
n: the number of successfully filled variables

Fetching the next file name from the specified folder

n = INPUT (folder, 0, 0, fileName)

If it succeeds, n will be 1. If there are no more files/subfolders the variable n will be set to zero.


Finishing Folder Scanning

CLOSE (channel)

Closes the folder identified by the channel value.

Listing a single folder

topFolder = open ("FileMan", "MyFavouriteFolder", "files, dialog")
y = 0
n = input (topFolder, 0, 0, fileName)
while n = 1 do
    text2 0, y, fileName
    y = y - 0.6
    n = input (topFolder, 0, 0, fileName)
close (topFolder)

This code segment (as the 2D script section of an object, for example) lists the files in the folder specified by the MyFavouriteFolder identifier.
At first usage, the user will have to assign an existing folder to this identifier.
Later, MyFavouriteFolder id will represent that folder.