Filenames

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > User manual introduction >

Filenames

Previous pageReturn to chapter overviewNext page

Gekko accepts relative paths, relative to the Gekko working folder. Consider, for instance, that you have a Gekko program file job.gcm with the following READ-statement inside the job.gcm file:

 

read \banks\data.gbk;

 

Now, Gekko will add the sub-folder \banks to the Gekko working folder path. If the Gekko working folder is C:\Projects\Model1, the READ statement is translated into:

 

read c:\Projects\Model1\banks\data.gbk;

 

You may use strings to compose file paths and names:

 

%s1 = 'Projects';
%s2 = 'Model1';
%s3 = 'banks';
%s4 = 'data';
read c:\{%s1}\{%s2}\{%s3}\{%s4};
read 'c:\{%s1}\{%s2}\{%s3}\{%s4}';

 

The two READ statements are equivalent: you may always use a string as a filename. More on string in the section on the STRING statement. Paths must use the \ (backslash) or / (forward slash), and it is recommended to begin a relative path with the \ or / character for clarity. It may be omitted though: for instance read banks\data; is equivalent to read \banks\data;. Double dots (..) can be used to indicate a parent folder, for instance \..\banks\bank.gbk. Example using forward slashes:

 

read c:/Projects/Model1/banks/data.gbk;

 

Valid file names consist of alphanumeric characters or the _ character. If the file name contains blanks or special characters (for instance the Danish æ, ø or å), you may enclose the file name in single quotes (read 'last year.gbk';).

 

See also the root() function that makes it easier to work with relative paths, making it possible to write for instance read {root()}\banks\data.gbk;., where the root is determined from the location of a special root.ini file.

 

Note that a path may "pass through" a zip file, like read c:\Projects\Model1\banks.zip\data.gbk;, where data.gbk is automatically extracted from the zip-file banks.zip. Such zip-file paths are only possible regarding the reading of different kinds of data files, and will not work for writing (repacking a file into a zip file).

 

At some point it may be preferable to add the sub-folder to the path of the executing Gekko program file, rather than to the Gekko working folder. Choosing between the two ways of interpreting relative path’s is not completely obvious, however.