MC-Basic:COMMON SHARED or DIM SHARED or DIM ... AS TYPE
Language: | English • 中文(简体) |
---|
Because a structure is a new data type, it must first be defined in configuration file. Only then the name of the new data type structure can be used to declare a structure variable.
Structure variables can be defined in all scopes, i.e., either in configuration file and from terminal (global variables), or within tasks, before (static variables) and within the Program block (local variables). Structures can also be defined as parameters of subroutines and functions, as well as returned-values of functions. A structure variable may be a scalar or an array. An array may have up to 10 dimensions.
Syntax for assigning a single element of a structure:
<structure_name>-><structure element name> =<expression>
Query single element of a structure syntax :
? <structure_name>-><structure element name>
Syntax
COMMON SHARED|DIM SHARED|DIM <structure_name> AS <structure type>
For arrays of structures:
COMMON SHARED|DIM SHARED|DIM <structure_name>[ ]… AS <structure type>
Availability
All versions
Type
<Structure type> is the declared structure type
Scope
Configuration or Terminal
Since Version 4.5.17 the global (common shared ) declaration is possible from the Library or Task contexts also .
Limitations
Write only. Structure type must be pre-defined in configuration file.
Examples
In config file ->
Type X
L1 as Long
Length as Long
End Type
In application file ->
Dim shared S1 as X
Program
S1->Length =2
?S1->Length
End program
See Also
- STRUCTURE TYPE DEFINITION
- COMMON SHARED ... AS LONG or DOUBLE or STRING or STRING OF UTF8
- DIM SHARED ... AS LONG or DOUBLE or STRING or STRING OF UTF8
- DIM ... AS LONG or DOUBLE or STRING or STRING OF UTF8
- COMMON SHARED or DIM SHARED or DIM ... AS JOINT OF ...
- COMMON SHARED or DIM SHARED or DIM ... AS LOCATION OF ...