Command STRUCT
 
Description Define a structure to group together related variables of different types in an efficient manner, for example databases and records.
Use the VAR(name,0,structName); command to create one, or VAR(name,0,structName,n) to create multiple instances, of the structure.
 
Syntax/Parameters STRUCT( strName )
{
var1, type1;
var2, type2;
....
}
 
Options Structures - STRUCT(){} - v49.42
* Structures are now supported in the firmware.
* To define a structure type (does not create actual structure at this point in code):

STRUCT( strName )
{
var1, type1;
var2, type2;
....
}

where
strName is the name for the structure
var1, var2 ... are the names for the variables in the structure
type1, type2 ... are the data types for the variables in the structure

* Limitations:
The concatenation of structure var name with underscores and indices must fit within an entity name length. Therefore structure var
names should be kept short.
The user must be careful not to create entities with the same name as the vars in the STRUCT - an error message will occur.

Structure support in FILE() and TEXT() commands - v49.44
* Structure variables can now be used in all the parameters in the FILE() commands.
* Structure variables can now be used for the source in the TEXT() command.

 
STRUCT(){} parameters now use '=' separator - v49.47
For consistency with STYLE() and SETUP(), the STRUCT() parameters now support '=' between the parameter name and parameter
type.
STRUCT(name)
{
name=type;
name,type;
}

DRAW() with Structures - v49.48
* DRAW() command now accepts structure parameters for width/height/angles/offset.
 
Example STRUCT( strPerson )
{
name, TXT;
age, U8;
height, U16;
weight, FLT4;
}

* To create a structure variable

VAR( name, 0, strName );

where
name is the name for your structure variable
0 is the intial value (not used)
strName is the name of the structure definition

Example:
VAR( Per, 0, strPerson ); // Create a structure for one person
LOAD( Per.name, "Itron" );
LOAD( Per.age, 100 );
LOAD( RS2, Per.name ); // will output "Itron"

* To create an array of structures

VAR( name, 0, strName, n, n, n );

where n is the number of subscripts

Example:
VAR( Co, 0, strPerson, 2, 5 ); // Create a structure for a company
LOAD( Co.0.0.name, "Mike" ); // First index used for department
LOAD( Co.0.0.age, 102 );
LOAD( Co.0.0.height, 100 );
LOAD( Co.0.0.weight, 8.4 );
LOAD( Co.0.1.name, "Andy" );
...
LOAD( Co.0.2.name, "Dave" );
...
LOAD( Co.1.0.name, "Bob" ); // Next department
LOAD( Co.1.0.age, 23 );
LOAD( Co.1.0.height, 180 );
LOAD( Co.1.0.weight, 12.4 );
LOAD( Co.1.1.name, "Mark" );
...

LOAD( RS2, Co.1.0.name, " aged ", Co.1.0.age, " is ", Co.1.0.height, "cm tall" ); // will output "Bob aged 23 is 180cm tall"
CALC( Co.0.2.age, Co.1.0.age, Co.0.0.age, "+" ); // will give Dave an age of 125

* How it works - multiple entities are created.

STRUCT( myStruc )
{
aa,U8;
bb,U16;
cc,TXT;
}

will effectively create 3 variables when STRUCT is defined:
VAR( aa, 0, U32C );
VAR( bb, 1, U32C );
VAR( cc, 2, U32C );

VAR( xx, 0, myStruc );

will effectively create (3+1) = 4 variables and set up the pointers:
VAR( xx > "", PTR, 3 );
VAR( xx_aa, 0, U8 ); LOAD( xx.0 > "xx_aa" );
VAR( xx_bb, 0, U16 ); LOAD( xx.1 > "xx_bb" );
VAR( xx_cc, "", TXT ); LOAD( xx.2 > "xx_cc" );

VAR( st, 0, myStruc, 3, 2 );

will effectively create (3*2*3+1) = 19 variables and set up the pointers:
VAR( st > "", PTR, 3, 2, 3 );
VAR( st_0_0_aa, 0, U8 );   LOAD( st.0.0.0 > "st_0_0_aa" );
VAR( st_0_0_bb, 0, U16 ); LOAD( st.0.0.1 > "st_0_0_bb" );
VAR( st_0_0_cc, "", TXT ); LOAD( st.0.0.2 > "st_0_0_cc" );
VAR( st_0_1_aa, 0, U8 );   LOAD( st.0.1.0 > "st_0_1_aa" );
VAR( st_0_1_bb, 0, U16 ); LOAD( st.0.1.1 > "st_0_1_bb" );
VAR( st_0_1_cc, "", TXT ); LOAD( st.0.1.2 > "st_0_1_cc" );
VAR( st_1_0_aa, 0, U8 );   LOAD( st.1.0.0 > "st_1_0_aa" );
VAR( st_1_0_bb, 0, U16 ); LOAD( st.1.0.1 > "st_1_0_bb" );
VAR( st_1_0_cc, "", TXT ); LOAD( st.1.0.2 > "st_1_0_cc" );
VAR( st_1_1_aa, 0, U8 );   LOAD( st.1.1.0 > "st_1_1_aa" );
VAR( st_1_1_bb, 0, U16 ); LOAD( st.1.1.1 > "st_1_1_bb" );
VAR( st_1_1_cc, "", TXT ); LOAD( st.1.1.2 > "st_1_1_cc" );
VAR( st_2_0_aa, 0, U8 );   LOAD( st.2.0.0 > "st_2_0_aa" );
VAR( st_2_0_bb, 0, U16 ); LOAD( st.2.0.1 > "st_2_0_bb" );
VAR( st_2_0_cc, "", TXT ); LOAD( st.2.0.2 > "st_2_0_cc" );
VAR( st_2_1_aa, 0, U8 );   LOAD( st.2.1.0 > "st_2_1_aa" );
VAR( st_2_1_bb, 0, U16 ); LOAD( st.2.1.1 > "st_2_1_bb" );
VAR( st_2_1_cc, "", TXT ); LOAD( st.2.1.2 > "st_2_1_cc" );
 
Update Information

 Version

 Title

Date  

 Details

49.47

 STRUCT(){} parameters now use '=' separator

01 Nov 13 

Show

For consistency with STYLE() and SETUP(), the STRUCT() parameters now support '=' between the parameter name and parameter type.

STRUCT(name)
{
name=type;
name,type;
}

49.44

 Structure support in FILE() and TEXT() commands

09 Oct 13 

Show

* Structure variables can now be used in all the parameters in the FILE() commands.
* Structure variables can now be used for the source in the TEXT() command.

49.42

 Structures - STRUCT(){}

06 Sep 13 

Show

* Structures are now supported in the firmware.
* To define a structure type (does not create actual structure yet):

STRUCT( strName )
{
var1, type1;
var2, type2;
....
}

where
strName is the name for the structure
var1, var2 ... are the names for the variables in the structure
type1, type2 ... are the data types for the variables in the structure

Example:

STRUCT( strPerson )
{
name, TXT;
age, U8;
height, U16;
weight, FLT4;
}

* To create a structure variable

VAR( name, 0, strName );

where
name is the name for your structure variable
0 is the intial value (not used)
strName is the name of the structure definition

Example:

VAR( Per, 0, strPerson ); // Create a structure for one person
LOAD( Per.name, "Itron" );
LOAD( Per.age, 100 );
LOAD( RS2, Per.name ); // will output "Itron"

* To create an array of structures

VAR( name, 0, strName, n, n, n );

where n is the number of subscripts

Example:

VAR( Co, 0, strPerson, 2, 5 ); // Create a structure for a company
LOAD( Co.0.0.name, "Mike" ); // First index used for department
LOAD( Co.0.0.age, 102 );
LOAD( Co.0.0.height, 100 );
LOAD( Co.0.0.weight, 8.4 );
LOAD( Co.0.1.name, "Andy" );
...
LOAD( Co.0.2.name, "Dave" );
...
LOAD( Co.1.0.name, "Bob" ); // Next department
LOAD( Co.1.0.age, 23 );
LOAD( Co.1.0.height, 180 );
LOAD( Co.1.0.weight, 12.4 );
LOAD( Co.1.1.name, "Mark" );
...

LOAD( RS2, Co.1.0.name, " aged ", Co.1.0.age, " is ", Co.1.0.height, "cm tall" ); // will output "Bob aged 23 is 180cm tall"
CALC( Co.0.2.age, Co.1.0.age, Co.0.0.age, "+" ); // will give Dave an age of 125


* How it works - multiple entities are created.

STRUCT( myStruc )
{
aa,U8;
bb,U16;
cc,TXT;
}

will effectively create 3 variables when STRUCT is defined:
VAR( aa, 0, U32C );
VAR( bb, 1, U32C );
VAR( cc, 2, U32C );


VAR( xx, 0, myStruc );

will effectively create (3+1) = 4 variables and set up the pointers:
VAR( xx > "", PTR, 3 );
VAR( xx_aa, 0, U8 ); LOAD( xx.0 > "xx_aa" );
VAR( xx_bb, 0, U16 ); LOAD( xx.1 > "xx_bb" );
VAR( xx_cc, "", TXT ); LOAD( xx.2 > "xx_cc" );


VAR( st, 0, myStruc, 3, 2 );

will effectively create (3*2*3+1) = 19 variables and set up the pointers:
VAR( st > "", PTR, 3, 2, 3 );
VAR( st_0_0_aa, 0, U8 ); LOAD( st.0.0.0 > "st_0_0_aa" );
VAR( st_0_0_bb, 0, U16 ); LOAD( st.0.0.1 > "st_0_0_bb" );
VAR( st_0_0_cc, "", TXT ); LOAD( st.0.0.2 > "st_0_0_cc" );
VAR( st_0_1_aa, 0, U8 ); LOAD( st.0.1.0 > "st_0_1_aa" );
VAR( st_0_1_bb, 0, U16 ); LOAD( st.0.1.1 > "st_0_1_bb" );
VAR( st_0_1_cc, "", TXT ); LOAD( st.0.1.2 > "st_0_1_cc" );
VAR( st_1_0_aa, 0, U8 ); LOAD( st.1.0.0 > "st_1_0_aa" );
VAR( st_1_0_bb, 0, U16 ); LOAD( st.1.0.1 > "st_1_0_bb" );
VAR( st_1_0_cc, "", TXT ); LOAD( st.1.0.2 > "st_1_0_cc" );
VAR( st_1_1_aa, 0, U8 ); LOAD( st.1.1.0 > "st_1_1_aa" );
VAR( st_1_1_bb, 0, U16 ); LOAD( st.1.1.1 > "st_1_1_bb" );
VAR( st_1_1_cc, "", TXT ); LOAD( st.1.1.2 > "st_1_1_cc" );
VAR( st_2_0_aa, 0, U8 ); LOAD( st.2.0.0 > "st_2_0_aa" );
VAR( st_2_0_bb, 0, U16 ); LOAD( st.2.0.1 > "st_2_0_bb" );
VAR( st_2_0_cc, "", TXT ); LOAD( st.2.0.2 > "st_2_0_cc" );
VAR( st_2_1_aa, 0, U8 ); LOAD( st.2.1.0 > "st_2_1_aa" );
VAR( st_2_1_bb, 0, U16 ); LOAD( st.2.1.1 > "st_2_1_bb" );
VAR( st_2_1_cc, "", TXT ); LOAD( st.2.1.2 > "st_2_1_cc" );

* Limitations:
The concatenation of structure var name with underscores and indices must fit within an entity name length. Therefore structure var names should be kept short.
The user must be careful not to create entities with the same name as the vars in the STRUCT - an error message will occur.