Opens a model in Desktop Analytica, or starts a new model. This causes your current model to be closed and removed from memory. If there are unsaved changes, you will be prompted to save changes, but otherwise, all previously computed results will be removed from memory. Because this closes your model, this is a dangerous function to use, and should only be used in specialized situations.
When Null is passed as «filename», it starts a new model, the same as would happen if you selected File / New on the menus.
When a textual filename is passed, it attempts to open that model, or brings up the file selector if the file doesn't exist or a directory name is given.
This file can only be used from the Typescript window, or from an OnClick event in desktop Analytica. The function cannot be used from ADE, ACP or Cubeplan. If you are using ADE, you can use CAEngine::OpenModel instead.
If the text
"[Example Models]" appears in «filename», this is replaced with the path to the example models directory.
This was introduced to make it possible to created a model selection page -- i.e., a page where you can list a bunch of models, and let the user click a button (or click on a Picture) to select a model.
Restricting permissions for launched model
This section describes a 'hidden' (not supported, subject to change, used internally) feature that can be used to restrict file access permissions of the model that is launched. This is not a feature we expect Analytica model builders to use. The feature first appears in Analytica 6.0.
Any "deny" restrictions also apply to models launched by that model using
There are two hidden optional parameters that you use to set up the access permissions.
OpenModelFile( filename ; folder, permission)
If you are granting access only to one folder, then «folder» and «permission» can be scalars. When configuring multiple folders, they are be 1-D arrays with a common index. Both are text (any null entries are ignored).
Each entry in «folder» is path to a directory (folder). Any relative paths are interpreted as being relative to CurrentDataFolder(). Subdirectory names must be separated with a backslash,
'\'. You can use
'.\' for current folder and
'..\' for parent folder. Other than these, there are no wildcards.
Each entry in «permissions» specifies whether read or write access is being allowed or denied to that folder and its subfolders. e.g.,:
"+rw": Allow read and write
"+r-w": Allow read, deny write
"-rw": Deny all access
"+r": Add read access to whatever is inherited
"-w": Deny write access to whatever in inherited
Each permission entry refines the entries that precede it. So, for example, if you specified:
«folder» «permission» "root" "-rw" "root\temp" "+rw"
then both read and write access to the
"root" folder is denied, with the exception of the subdirectory
"temp" (and its sub-folders) for which both read and write access is granted.
When you specify any folder permission, it starts out denying access to all folders with the exception of the Analytica installed libraries folders, which are granted read access. If your model was launched with restrictions, and your model is calling OpenModelFile() to open yet another model, then it starts with the restrictions that are currently in place, but from there you can only make it more restrictive (you can't give the launched model access that your current model does not have).
The file access permissions impact Analytica's built-in file functions and command, such as: ReadTextFile(), ReadBinaryFile(), ReadImageFile(), SpreadsheetOpen(), WriteTextFile(), WriteBinaryFile(), WriteImageFile(), SpreadsheetSave(), ReadFile command, and others.
Introduced in Analytica 5.0.
A hidden feature to restrict file access permissions by the launched model was introduced in Analytica 6.0.