The concept of different types of variables allows a first (“coarse”)
typification of variables (control or iconic data), whereas the actual type of
the data for example, real, integer, string etc., is undefined until
a concrete value is assigned to the variable. Therefore, it is possible that
the data type of a new data item differs from that of the old.
In HDevelop, the type of a variable is defined in three different ways:
- procedure parameter definitions (explicitly)
- global variable declarations (explicitly)
- usage in the code (implicitly)
The order of precedence is as follows:
- Procedure parameter definitions
- Global variable declarations
- Usage in the code
In the latter case, the type of a variable is defined by those code lines,
where the value of the variable is used and
where the exact type of the new value is known before run
time.
Within its scope, a variable must always be properly defined. The following
type definition errors are possible:
- A local variable is used, whose type has not been defined before.
→ The error 'The variable never gets initialized' [21089] is
thrown. All lines using the variable will become invalid, and the variable
will not be displayed in the variable window.
- The type of a variable is defined differently, for example, as iconic variable
and later as control variable.
→ The error 'The type of
the variable could not be determined (conflicting type definitions found)'
[21088] is thrown. All lines using the variable will become invalid, and the
variable will not be displayed in the variable window.
- The type of a variable is properly defined, but used in the wrong context,
for example, an iconic variable is used as a control input parameter.
→ The error 'The type of the variable could not be determined
(conflicting type definitions found)' [21088] is thrown. Only the affected
code will become invalid.