The Main Application Methods
The following table lists the most important methods for the main application class AppModel:
Returns the declaration object (Scalar, Array 1D, Array 2D, ChoiceList, or UnitSet) with the specified name.
Returns the MainWindow object.
You can view additional methods by using Ctrl+Space for code completion.
The AppModel class has the following properties:
true | false
edit | run
Example Code
app.set("asktosave", true);
The following code appends a text string to the application window title.
String oldTitle = app.mainWindow().getString("title");
app.mainWindow().set("title", oldTitle + " modified");
The following examples show how to query the list of declarations in an application.
// Get the declaration list
Declaration list = app.declaration();
// Get the names of all DataSource objects in the list.
String[] names = list.names();
// Get the number of DataSource objects in the list.
int size = list.size();
// Get the DataSource with the name "svar".
DataSource src = list.get("svar");
// Get the index within the list of the DataSource with the name "svar".
int index = list.index("svar");
// Get the DataSource at a certain index within the list.
DataSource src = list.get(index);
// Get the DataSource objects defined in a given form.
Declaration formDeclarations = app.form("form1").declaration();
// Iterate over DataSource objects within the list.
for(DataSource dt : list) {
// Get the type of the DataSource.
String type = dt.getType();
}