...
Code Block | ||||
---|---|---|---|---|
| ||||
FUNCTION xpfAddToAggrIfNotInAggr (aggr : AGGREGATE OF GENERIC; elementelementValue : GENERIC) inserted : BOOLEAN; |
Use this function to add an element to aggregate (or append) the given 'elementValue' to the specified aggregate 'aggr' if the aggregate does not have an element with the same value.
xpfAddToAggrIfNotInAggr(aggr, element) performs the same as the following statements:
IF NOT (element IN aggr) THEN aggr ++ element; END_IF;
Arguments
...
Type | Name | Comment | ||||
AGGREGATE OF GENERIC | aggrId | comments | GENERIC | instanceId | Any aggregate type except ARRAY. The aggregate elements data type must be compatible with the data type of the argument 'elementValue'. If the aggregate is a LIST, the actual 'elementValue' will be appended to the list. | |
GENERIC | elementValue | The value to add to the aggregate if the actual value does not exist in the aggregate. The 'elementValue' can be any of the following data types: sdaiINSTANCE, sdaiINTEGER, sdaiREAL, sdaiSTRING and "typed value" of sdaiINTEGER, sdaiREAL, sdaiSTRING |
Return Value
...
Type | Name | Comment |
BOOLEAN | inserted | TRUE if the element was added |
Options
...
Example
Code Block | ||
---|---|---|
| ||
LOCAL
OK : BOOLEAN;
str : STRING;
aggr: LIST OF STRING;
END_LOCAL;
...
str := 'QWERTY';
OK := xpfAddToAggrIfNotInAggr(aggr, str);
IF OK THEN
xpxPrintf('\n%s inserted', str);
END_IF;
... |
...
FUNCTION get_unique_references(referred: GENERIC): SET OF GENERIC;
LOCAL
not_unigue_refs : BAG OF GENERIC;
unigue_refs : SET OF GENERIC;
END_LOCAL;
not_unigue_refs := USEDIN(referred,?);
unigue_refs := [];
REPEAT i:=1 TO xpfSizeOf(not_unigue_refs);
IF xpfAddToAggrIfNotInAggr(unigue_refs, not_unigue_refs[i]) THEN
xpxPrintf('\n%s inserted', not_unigue_refs[i].name);
END_IF;
END_REPEAT;
RETURN(unigue_refs);
END_FUNCTION;
See also
Filter by label (Content by label) | ||||||
---|---|---|---|---|---|---|
|
...