Skip to content

AVAL ​

Retrieve the value from an attribute and stores it in a variable.

Syntax ​

leo-grammar
AVAL [ as-original-type ] [ set-default:anyValue ]
    [ set-count-rows ] [ set-row:intValue set-col:strValue ]
    [ set-format:strValue ] [ set-sep:strValue ]
    VariableName:AttributeName .

VariableName : LowerCaseIdentifier .

AttributeName : strValue .

Parameters ​

  • VariableName (LowerCaseIdentifier) - The name of the variable to set.
  • AttributeName (strValue) - The name of the attribute to retrieve the value from.
  • as-original-type (modifier, optional) - When specified then the value will be according to the attribute's type. Otherwise the value will always be a string. By default this is not specified.
  • set-default (anyValue, optional) - A default value to use in cases where no specific object yet exists, like the "Modelling bar" in the Modelling Toolkit or debugging the GraphRep code.
  • set-count-rows (modifier, optional) - When specified then the variable is set with the amount of rows used in a record type attribute. By default this is not specified.
  • set-row (intValue, optional) - Used for record type type attributes to retrieve the value of a specific cell. This defines in which row the cell is located, with row numbering starting at 1.
  • set-col (strValue, optional) - Used for record type type attributes to retrieve the value of a specific cell. This defines the name of the column where the cell is located.
  • set-format (strValue, optional) - The format in which to return values from an Inter-model reference type attribute.
  • set-sep (strValue, optional) - The separator to use between values when an Inter-model reference type attribute contains more than one value. The default is "\r\n".

Details ​

The AVAL command assigns attribute values of the current object to runtime variables. The value specified behind the VariableName has to be a string. This is interpreted as the name of the instance attribute to be evaluated. The value of this instance attribute is calculated and assigned to the runtime variable. The AVAL command can also be used to read both instance and class attributes.

The variables set in this way can be used in other commands, like positions of shapes, colors of styles or conditions of IF, ELSIF and ELSE. This enables the system to make attribute-dependent graphical representations.

The symbols in the "Modelling bar" (of the Modelling Toolkit) do not belong to concrete objects. Therefore, AVAL uses the default values of the instance attributes when evaluating them. This could lead to an undesired representation in the modelling panel. Providing a value via the set-default parameter allows to assign a different value to the variable for the representation in the "Modelling bar". The set-default parameter is also useful for debugging GraphRep code, as it allows to test different values for the variable.

By default the value of an attribute is always stored as a string (strValue) in the variable. If the parameter as-original-type is specified, then the value will have the same (or closest fitting) type as the attribute.

With set-count-rows and set-row/set-col it is possible to access values of record type attributes. Through set-count-rows the amount of rows in a table can be assigned to a variable. With set-row and set-col the access to a specific table cell can then be defined, for example inside of a FOR loop.

The format of for values of Inter-model reference type attributes to be stored in the variable can be provided through the set-format parameter. The value should be a string specifying the format and can use the following placeholders which are replaced accordingly:

  • %o with the object name,
  • %c with the class name,
  • %m with the model name,
  • %M with the model basename (only analyzed in application libraries with time-related versioning),
  • %t with the model type name;
  • %v with the internal version number (in format: YYYY:MM:TT, only analyzed in application libraries with time-related versioning),
  • %V with the internal version number defined in the format of versioning (only analyzed in application libraries with time-related versioning).

When an Inter-model reference attribute has more than one value, then the text specified for set-sep is used between each of them. It can contain more than one character and is by default "\r\n", which writes each reference in a new line.

See Also ​

Examples ​

Depending on the value of the attribute "Value" (of integer type), draw a minus sign "-" if it is negative or otherwise a plus sign "+".
A minus sign followed by two plus signs

leo
GRAPHREP

AVAL as-original-type nValue:"Value"
TEXT (cond(VAL nValue < 0, "-", "+"))

Print the first three letters of the value of the attribute "Continent", prepend it with a "c: " and center it horizontally. Use the "Courier New" font for the text. Unlike ATTR it does not provide the typical interaction with the attribute (click value to open input window).
The text c: Afr

leo
GRAPHREP

AVAL sContinent:"Continent"
FONT "Courier New"
TEXT ("c: " + copy(sContinent, 0, 3)) w:c

Show a warning text when the "Description" attribute has an empty value. However, as the default value for "Description" is empty: do not show this warning in the "Modelling bar".
A rectangle with the text "<Description missing!>" inside of it, followed by a rectangle without that text and then the object's notation without the "<Description missing!>" text in the Modelling bar

leo
GRAPHREP

AVAL set-default:"xyz" sDescription:"Description"
RECTANGLE x:-1.8cm y:-0.5cm w:3.6cm h:1cm
IF (NOT LEN sDescription) {
  TEXT "<Description missing!>" w:c h:c
}

Draw a list of all departments from the "Responsible Persons" record type attribute underneath a plain rectangle.
Two rectangles and under each one a list of the departments (Design and Logistics; Finance, Development and Development)

leo
GRAPHREP

AVAL set-count-rows nRowCount:"Responsible Persons"
FILL color:"white"
RECTANGLE x:-1.2cm w:2.4cm h:0.8cm
FOR nI from:1 to:(nRowCount) {
  AVAL set-row:(nI) set-col:"Department" sDepartment:"Responsible Persons"
  TEXT (sDepartment) x:0cm y:(0.5cm + (nI * 0.5cm)) w:c h:t
}

Versions and Changes ​

Available since ADOxx 1.3