... | ... | @@ -22,15 +22,27 @@ Finally, GetDP also defines a `SendToServer` option in its `PostOperation` objec |
|
|
|
|
|
## DefineNumber and DefineString
|
|
|
|
|
|
The purpose of these commands is to associate a local variable in the namespace of Gmsh or GetDP with a shared parameter in the ONELAB database whose value is accessible to all clients and can be set interactively by the user in the graphical user interface.
|
|
|
|
|
|
When an input `.geo` or `.pro` file is parsed, the command
|
|
|
|
|
|
```cpp
|
|
|
n = DefineNumber[ 3.14, Name "a number", <attributes...>];
|
|
|
```
|
|
|
first checks if a ONELAB parameter with name `"a number"` exists in the ONELAB database.
|
|
|
* If not, the parameter `"a number "` is added to the ONELAB database with value `3.14`, and the same value is also assigned to the local variable `n` in the namespace of Gmsh or GetDP.
|
|
|
* If it does, it is the value fetched from the ONELAB database that is assigned to the local variable `n`, and the argument value of the command is ignored.
|
|
|
|
|
|
This means that `3.14` can be interpreted as a default value for the local variable `n` (and for the ONELAB parameter `"a number"`): the first time the statement `n = DefineNumber[ 3.14, Name "a number"]` is parsed, the local variable `n` is assigned the default value `3.14`. All subsequent executions of a command like `n = DefineNumber[ 2.718, Name "a number"]` (in the same file if it is parsed again or in another file) will ignore the argument value `2.718` and assign to the local variable `n` the value of `"a number"` obtained from the ONELAB database. That value could be the original default value, or a value set in the meantime by the user via the graphical user interface, or a value set by another ONELAB client.
|
|
|
|
|
|
Sometimes the opposite behavior is useful. This is done by giving the ONELAB parameter the attribute `ReadOnly 1`, e.g. by means of the command
|
|
|
|
|
|
first checks if the ONELAB parameter with name `"a number"` exists in the ONELAB database. If not, it is created in the ONELAB database with value `3.14`. The same value is also assigned to the local Gmsh or GetDP variable `n`. A `/` character in a parameter name is interpreted as a path separator, and results in the creation of a sub-tree in the graphical user interface. If the same input file is re-analyzed later, or if another input file is parsed and the ONELAB parameter `"a number"` already exists in the database, its associated value is fetched and is assigned to the local variable `n` (unless it is labeled `ReadOnly`: see below for all the optional attributes that can be specified in addition to the `Name` of the parameter).
|
|
|
```cpp
|
|
|
n= DefineNumber[2.718, Name "a number", ReadOnly 1, <attributes...> ] ;
|
|
|
```
|
|
|
In this case, the parameter `"a number"` in the ONELAB database and the local variable `n` are both assigned the argument value, here `2.718`. All subsequent `n = DefineNumber[ xx , Name "a number"]` statements will have the same behavior, as long as the attribute `ReadOnly' of the parameter `"a number"` is not reverted to 0. Logically, `ReadOnly` parameters are not editable in the graphical user interface.
|
|
|
|
|
|
This means that `3.14` can be interpreted as a default value for the local variable `n` (and the ONELAB parameter `"a number"`): the first time `n = DefineNumber[ 3.14, Name "a number"]` is parsed, `n` will be assigned the default value `3.14`. The next time, `n` will be assigned whatever value is associated with the `"a number"` parameter in the ONELAB database. The value in the database could be the original default value, a value set by the user in the graphical user interface, or a value set by another ONELAB client.
|
|
|
A `/` character in a parameter name results in the creation of a sub-tree in the hierarchical parameter tree displayed in the menu panel of the graphical user interface. See also below for all the optional attributes that can be specified in addition to the `Name` of the parameter.
|
|
|
|
|
|
If no ONELAB server exists (e.g. if GetDP is run in stand-alone mode), the `DefineNumber` command simply assigns the default value `3.14` to the local variable `n`. An input file using `DefineNumber` to create an appealing graphical user interface using ONELAB can thus also be run as-is without ONELAB.
|
|
|
|
... | ... | |