getlistitems
Copy multiple items from a list into a field or variable.
getlistitems IndexedList,Field
getlistitems/id AssociativeList,Target
where Target can be:
- Field
- IdField
- {IdField}
,
ValueField
getlistitems/id {/field | /component | /global} AssociativeList
getlistitems/occ {/init} AssociativeList,Entity
Detailed Syntax
- Fill one field in successive occurrences with
indexed list items:
getlistitems IndexedList
,
Field - Fill one field in successive occurrences with
the value part of an associative list:
getlistitems/id AssociativeList
or
getlistitems/id AssociativeList
,
,
ValueField - Fill two fields in successive occurrences
with the ID and value parts of an associative list:
getlistitems/id AssociativeList,IdField,IdValue
- Fill fields of the current occurrence with
the value parts of an associative list, where the ID part of the list represent the field names:
getlistitems/occ List,Entity
- Fill the fields or variables that match the
ID part in an associative list with the value parts of associative list items:
getlistitems/id /field | /component | /global List
Qualifiers
Qualifier | Description |
---|---|
/id | Copies items from an associative list |
/field | Copies the value part of items in an associative list to the corresponding field |
/component | Copies the value part of items in an associative list to the corresponding component variable |
/global | Copies the value part of items in an associative list to the corresponding global variable |
/occ | Copies the value part of items in an associative list into the corresponding fields of the specified entity |
/init | Sets the value of the target field in a non-database occurrence without locking the occurrence or changing the status of $fieldmod, $occmod, $occdbmod, $formmod, $instancemod, or $instancedbmod. |
Parameters
Parameter | Data Type | Description |
---|---|---|
IndexedList
AssociativeList |
String | Variable or field containing an indexed or associative list |
Field | String | Component field. |
IdField | String | Id part in an associative list |
ValueField | String | Value part in an association list |
Entity | String | Component entity whose occurrence fields are to be filled. |
Return Values
Value | Description |
---|---|
0
|
No items were copied. |
>0 |
Number of the items copied. |
Use
Allowed in all component types.
However, getlistitems/id/global cannot be used in self-contained Service and Report components.
Description
Use the getlistitems statement
to copy data from an indexed list of values or an associative list of ID=value
pairs. For more information, see Lists and Sublists.
Use getlistitems without qualifiers to copy the contents of items in an indexed list to a field in successive occurrences of its parent entity.
You can use getlistitems/id to copy:
- The ID and value parts of items in an associative list into the fields IdField and ValueField in successive occurrences of the current entity.
- The value of items in an associative list into the fields or variables that are identified by the associated ID of each item.
You can use getlistitems/occ to copy the value part of items in an associative list into the fields of the named Entity that are identified by the associated ID of each item.
Copying to Successive Occurrences
When items are copied from a list into a field or pair of fields in successive occurrences of an entity, the first list item is copied into the current occurrence and new occurrences are created for the subsequent items.
When copying data into successive occurrences, if one of the specified fields occurs in an Up entity, then the nearest outer Down entity is used to control the movement of data into occurrences. If both of the fields specified are Up entities, the nearest outer entity of the first field controls the movement.
Filling One Field in Successive Occurrences
To copy items from an indexed list to a single field in successive occurrences, use getlistitems with no switch. Each item is copied to the indicated field in successive occurrences of its entity. If an unqualified field name is used, the current entity is used. The entire item is copied to Field, even if the item is structured like an associative list item.
Filling One or Two Fields From Associative Lists
To copy list items into one or two fields in successive occurrences, use getlistitems with the /id switch and at least one of IdField and ValueField.
- If both IdField and ValueField are present, for each item in the associative list, the ID part of the item is copied to the field IdField and the value part is copied to the field ValueField in successive occurrences.
- If IdField is omitted, only the values are copied.
- If ValueField is omitted, only the IDs are copied.
Copying Values of List items Into Targets
To copy the value part of each item in an associative list into the target specified by the ID part of that item, use getlistitems/id , a List name, and no further arguments. The ID part of the item can contain the name of a field, a component variable, a global variable, or a general variable. For example:
vList = "NAME=Frodo;$LOC_TOT$=14;$$GLOB_TOT=329;$1=-8" getlistitems/id vList
After these statements have been executed, the
field NAME field contains Frodo
, the component variable $LOC_TOT$ contains 14
, the global variable $$GLOB_TOT contains 329
and the general variable $1
contains -8
.
For each item, if the field or variable named by the item ID cannot be found, no action is taken.
The ID part of the list item is assumed to be a field name if it does not contain a dollar sign ($). If the ID part includes a dollar sign, it is treated as the variable type specified. However, if one of the target qualifiers /field, /component, or /global is specified, Item IDs that do not include a dollar sign are treated as the selected source type.
For example, a field NAME, a component variable $NAME$ and a global variable $$NAME are all available, as well as a field TOTAL and a component variable $TOTAL$:
NAME = ""
$NAME$ = ""
$$NAME = ""
TOTAL = 0
$TOTAL$ = 0
vList = "NAME=Frodo;$TOTAL$=123.45"
getlistitems/id vList
;NAME is Frodo, $TOTAL$ Is 123.45, TOTAL Is 0
getlistitems/id/field $LIST$
;NAME is Frodo, $TOTAL$ Is 123.45, TOTAL Is 0
getlistitems/id/component $LIST$
;$NAME$ is Frodo, $TOTAL$ Is 123.45, TOTAL Is 0
getlistitems/id/global $LIST$
;$$NAME is Frodo, $TOTAL$ Is 123.45, TOTAL Is 0
Note: Although it is usually good practice to include the dollar signs ($) that form part of the variable name in each list item's value, these must be omitted to take advantage of the power of the target switches.
Because the list argument is evaluated at run time, you should consider the following points when you create the component:
- The existence of the referenced objects (fields and variables) cannot be verified by the compiler
- Any referenced fields cannot be included in an Automatic field list
Be sure that all the fields that will be referenced are included in the entity's field list and that all the component and global variables are defined.
Filling Fields in an Entity
You can use getlistitems/occ to copy the value part of associative list items into the fields of the current occurrence of the specified Entity. The field name must match the ID part of the list items. If a field is not available in the component, the item is not copied. Specifying Entity makes it possible to identify the uniquely entity in case of duplicate field names.
Using getlistitems
In the examples below, ; and !; ) represent the Uniface Gold subfield separators.
The following example copies the three items of an indexed list into the field DAY in the current occurrence and two added occurrences of the entity CALENDAR:
$LIST$ = "Monday;Tuesday;Wednesday" setocc "CALENDAR", 1 ; Make first occurrence current getlistitems $LIST$, DAY.CALENDAR ; DAY of current occurrence is "Monday" ; DAY of 1st added occurrence is "Tuesday" ; DAY of 2nd added occurrence is "Wednesday"
The following example copies the three items of an associative list into the fields NUM and NAME in the current occurrence and two added occurrences of the entity CALENDAR. The associated parts of the ValRep of each item are placed in the fields NUM and NAME.
$LIST$ = "d1=Mon;d2=Tue;d3=Wed" setocc "CALENDAR", 1 ; Make first occurrence current getlistitems/id $LIST$, NUM.CALENDAR, NAME.CALENDAR ; NUM is "d1" and NAME is "Mon" of current occ ; NUM is "d2" and NAME is "Tue" of added occ ; NUM is "d3" and NAME is "Wed" of added occ
For each item in an associative list, the following example copies the representation part of the item into the field (in the current entity) identified by the value part of the item:
$LIST$ = "day1=Mon;day2=Tue;day3=Wed" getlistitems/id/field $LIST$ ; copies "Mon" to field DAY1 ; copies "Tue" to field DAY2 ; copies "Wed" to field DAY3
For each item in an associative list, the following example copies the representation part of the item into the component variable identified by the value part of the item:
$LIST$ = "day1=Mon;day2=Tue;day3=Wed" getlistitems/id/component $LIST$ ; copies "Mon" to component variable $DAY1$ ; copies "Tue" to component variable $DAY2$ ; copies "Wed" to component variable $DAY3$
For each item in an associative list, the following example copies the representation part of the item into the global variable identified by the value part of the item:
$LIST$ = "day1=Mon;day2=Tue;day3=Wed" getlistitems/id/global $LIST$ ; copies "Mon" to global variable $$DAY1 ; copies "Tue" to global variable $$DAY2 ; copies "Wed" to global variable $$DAY3
For each item in an associative list, the following example copies the representation part of the item into the target identified by the value part of the item. The type of the target (that is, whether it is a field or variable) is derived from the value of the item.
$LIST$ = "day1=Mon;$day2$=Tue;$$day3=Wed";$9=Thu getlistitems/id $LIST$ ; copies "Mon" to the field DAY1 ; copies "Tue" to component variable $DAY2$ ; copies "Wed" to global variable $$DAY3 ; copies "Thu" to general variable $9
For each item in an associative list, the
following example copies the representation part of the item into the field (of entity WEEK)
identified by the value part of the item. Notice that this is similar to the first example above
using the /field
switch, except that the target entity name is specified with the
getlistitems/occ
statement.
$LIST$ = "day1=Mon;day2=Tue;day3=Wed" getlistitems/occ $LIST$, "WEEK" ; copies "Mon" to the field DAY1.WEEK ; copies "Tue" to the field DAY2.WEEK ; copies "Wed" to the field DAY3.WEEK