Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
05 ArchiCAD 11 GDL Reference Guide.pdf
Скачиваний:
60
Добавлен:
11.03.2015
Размер:
3.22 Mб
Скачать

Miscellaneous

Reading Information

n = INPUT (channel, "", "", datetimestr) channel: channel value

datetimestr: string type value

It reads a string type value which represents the date and/or time in the format given at the OPEN sequence. The second and third parameters are unused (they can be empty strings or 0-s as well).

The return value is the number of successfully read values, in this case 1.

Closing Channel

CLOSE channel

Closes the channel identified by the channel value.

GDL FILE MANAGER I/O ADD-ON

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

What would you like to search 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.

For example, the line

folder = OPEN( "FileMan", "c:\\\

ArchiCAD 11 GDL Reference Guide

301

Miscellaneous

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

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 succesfully filled variables

For example, the line

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

fetches the next file name from the specified folder, and returns 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.

Example: Listing a single folder

The following 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.

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 ) endwhile

close( topFolder )

302

ArchiCAD 11 GDL Reference Guide