Below are the main services to declaring data structures.
Declaration:
paCreateStruct - Create a data
structure
paSetStructComment - Set the desrciption
text of a structure
Working with existing data structures:
paEnumStruct - Enumerate data
structures
paGetStructDesc - Get information about a
data structure
paDeleteStruct -
Remove a data structure
Below are details about these functions:
OK := paCreateStruct (NAME)
Parameters:
NAME : STRING; | Name of the structure |
OK : BOOL; | True if successful |
Description:
This function creates a data structure in the target project.
OK := paSetStructComment (NAME, COMM)
Parameters:
NAME : STRING; | Name of the structure |
COMM : STRING; | Description text |
OK : BOOL; | True if successful |
Description:
This function sets the comment text of a data structure.
function block: Inst_paEnumStruct (LOAD, CHECK, ITEM, FILTER)
Input parameters:
LOAD : TRUE; | If TRUE, load the list of structures |
CHECK : BOOL; | If TRUE, open a checklist box to select some of the loaded structures |
ITEM : DINT; | Index of the item wanted on input (1 based) |
FILTER : STRING; | Filtering mask for loading structures |
Ouputs:
NB : DINT; | Number of structures |
Q : STRING; | Name of the item selected with "ITEM" |
Description:
This function block is used for enumerating the data structures of the target project. You must first call it with LOAD input at TRUE in order to load the list of structures. You get the number of structures in the NB output. Then call it again with LOAD at FALSE and specifying the index of the wished structure in the ITEM input to get the name of the selected item in the Q output. The numbering of items starts at 1.
When loading structures (LOAD inputs is TRUE), you can specify a filtering string that may include some '*' or '?' wildchars.
After loading, if can call again the block with the CHECK input at TRUE for opening a dialog box where the user can check wished structures. After the box is closed, only checked items remain in the loaded list.
Example:
// "ENU" is a declared instance of
paEnumStruct function block
// load all
structures
ENU (TRUE, FALSE, 0,
'*');
// open a dialog box for
the user to check wished items
ENU
(FALSE, TRUE, FALSE, 0, '');
// enumerate checked
items
for i := 1 to ENU.NB do
//
select the item
"i"
ENU
(FALSE, FALSE, i, '');
//
get the name of the item specified by
"i"
sProgName
:= ENU.Q;
end_for;
function block: Inst_paGetStructDesc (NAME)
Input parameters:
NAME : STRING; | Name of the structure |
Ouputs:
OK : BOOL; | TRUE if successful |
COMMENT : STRING; | Description text |
Description:
This function block is for getting information about a structure of the target project.
OK := paDeleteStruct (NAME)
Parameters:
NAME : STRING; | Name of the structure (see notes) |
OK : BOOL; | True if successful |
Description:
This function deletes the specified structure. The "NAME" parameter can contain '?' and '*' wildchars. For instance, paDeleteStruct ('*') deletes all the structures of the target project.