FileParameter=

Parent Previous Next

Full Library / Model / Parameter / FileParameter
Block Name: FileParameter

Code File Location: VisualSim/data/expr/FileParameter

 

Description

This is an attribute that specifies a file or URL. The value of this attribute, accessed by getExpression(), is a string that names a file or URL, possibly containing references to variables defined in scope using the syntax $ID, ${ID} or $(ID). The value returned by getToken() is name of the file with such references resolved.

If this attribute contains a parameter named allowFiles with value false, then when a file browser is used to select a file, that file browser will be set to not show files (only directories will be shown). If this attribute contains a parameter named allowDirectories with value true, then the file browser will permit the user to select directories (the default behavior is that when a directory is selected, that directory is opened and its contained files and directories are listed).

If the model containing this attribute has been saved to a MoML file, then the file name can be given relative to the directory containing that MoML file. If the model has not been saved to a file, then the classpath is used for identifying relative file names.

Files can be given relative to a base, where the base is the URI of the first container above this one that has a URIAttribute. Normally, this URI specifies the file or URL containing the model definition. Thus, files that are referred to here can be kept in the same directory as the model, or in a related directory, and can moved together with the model.

The following special file names are understood:
    * System.in: Standard input.
    * System.out: Standard output

Note: These file names cannot be converted to URLs using the asURL() method. A file name can also contain the following strings that start with "$", which get substituted with the appropriate values.

Property

Description

$CWD

The current working directoryuser.dir$HOME

$VS

The home directory of the VisualSim installation $TMPDIR and The temporary directoryjava.io.tmpdir

The above properties are normally set when a VisualSim application starts.

If a file name begins with the reference "$CLASSPATH", then when the file is opened for reading, the openForReading() method will search for the file relative to the classpath (using the getResource() method of the current class loader). This will only work for a file that exists, and thus the openForWriting() method will not understand the "$CLASSPATH" string; this makes sense since the classpath typically has several directories, and it would not be obvious where to create the file. The asURL() method also recognizes the "$CLASSPATH" string, but not the asFile() method (which is typically used when accessing a file for writing).

NOTE: If the container of this parameter also contains a variable named CLASSPATH, then the value of that variable is used instead of the Java classpath.

Since:

VisualSim 4.0

See Also:

URIAttribute

Created with the Personal Edition of HelpNDoc: Free EPub and documentation generator