184
Manual – IPOSplus®
14
User-defined structures
Compiler – Programming
14.9 User-defined structures
Users can define their own structures in addition to the SEW standard structures. First
of all, the structure must be created. This is done in the declaration part of the program.
The 'typedef struct' keyword is used for this. This can be explained by taking an example
which creates a position table.
This creates a structure with the name
table
. You can now use this structure as ex-
plained for the standard structures. The next step is to declare a variable as the structure
variable.
Now the variable PosTable has been declared as a structure variable of the structure
type
table
. The next step is to access the elements. The table must be initialized to do
so.
The following is a general description of the procedure for setting up a user structure:
The insert tool can also be used for user-defined structures. To do so, from the Pre-de-
fined Structures window of the insert help choose ’typedef struct (user defined)’. Now
you can change the name of the elements and the structure.
// Define user structure
typedef struct
{
long pos1;
long pos2;
long pos3;
long pos4;
long pos5;
} table;
// Declare structuretable postable;
// Initiate
postable.pos1 = 100000;
postable.pos2 = 120000;
postable.pos3 = 50000;
postable.pos4 = 200000;
postable.pos5 = 10000;
typedef struct
{
Type Identifier1;
Type Identifier2;
...
Type IdentifierN;
} Structure name;
StructureName VariableName;
VariableName.Identifier1 = ...;
VariableName.Identifier2 = ...;
VariableName.IdentifierN = ...;
P
i
f
kVA
Hz
n
P
i
f
kVA
Hz
n