OPENPATH pathname [TO filevariable] [SETTING var] [ON ERROR statements] [[THEN statements] [ELSE statements]]
|pathname||Optional — A fully-qualified pathname of a directory, specified as a quoted string. For example: “C:\foo\”|
|TO filevariable||Optional — A structure that contains the file type and the file name. For details, see below.|
|SETTING var||Optional — When an error occurs, sets the local variable var to the operating system's error return code. Successful completion returns 0; error return codes are platform-specific. The SETTING clause is executed before the ON ERROR, THEN, or ELSE clause. Provided for jBASE compatibility.|
OPENPATH opens a directory. Each filename within the directory is represented as a record ID. Subsequent READ statements specify these files using the record IDs.
The filevariable string has the following structure:
The FileType codes are as follows: 0=Select List; 1=OS File; 2=Directory; 3=Global
The DictFlag codes are as follows: 0=data file; 1=dictionary file
FileName1 specifies (depending on the FileType) the file name, directory name, or global name.
FileName2 is only specified for FileTypes 2 and 3: If FileType 2=the VOC id for the OS file name. If FileType 3 = the VOC id for the file name.
The filevariable argument accepts a single dynamic array reference (A<i>), a single substring reference (A[s,l]), or a substring reference nested inside a dynamic array reference (A<i>[s,l]).
You can optionally specify an ON ERROR clause, which is executed when the directory is located but could not be opened. The ELSE clause is executed when the directory could not be located. If no ON ERROR clause is specified, the ELSE clause is executed for both types of failed access. The statements argument can be the NULL placeholder keyword, a single statement, or a block of statements terminated by the END keyword. A block of statements has specific line break requirements: each statement must be on its own line; there must be a line break between the ON ERROR keyword and the first line.
You can optionally specify a THEN clause, an ELSE clause, or both a THEN and an ELSE clause. If the directory open succeeds, the THEN clause is executed. If the directory open fails, the ELSE clause is executed. The statements argument can be the NULL keyword, a single statement, or a block of statements terminated by the END keyword. A block of statements has specific line break requirements: each statement must be on its own line and cannot follow a THEN, ELSE, or END keyword on that line.