version 2004 (Modified)
List item parent (list; itemRef | *) Longint
Parameter | Type | Description | |
list | ListRef | List reference number | |
itemRef | * | Longint | * | Item reference number or | |
0 for the last item added to the list or | |||
* for the current item in the list | |||
Function result | Longint | Item reference number of parent item or | |
0 if none |
Description
The List item parent command returns the item reference number of a parent item.
You pass a list reference number in list; you pass the item reference number of an item in the list or 0 or yet again *, in itemRef. If you pass 0, the command applies to the last item added to the list. If you pass *, the command applies to the current item of the list. If several items have been selected manually, the current item is the last one selected.
In return, if the corresponding item exists in the list and if this item is in a sublist (and therefore has a parent item), you obtain the item reference number of the parent item.
If there is no item with the item reference number you passed, or if you have passed * and no item is selected, or if the item has no parent, List item parent returns 0 (zero).
If you work with item reference numbers, be sure to build a list in which the items have unique reference numbers; otherwise you will not be able to distinguish the items. For more information, see the description of the APPEND TO LIST command.
Examples
Given the list named hList shown here in the User environment:
The item reference numbers are set as follows:
Item | Item Reference Number |
a | 100 |
a - 1 | 101 |
a - 2 | 102 |
b | 200 |
b - 1 | 201 |
b - 2 | 202 |
b - 3 | 203 |
In the following code, if the item "b - 3" is selected, the variable $vlParentItemRef gets 200, the item reference number of the item "b":
$vlItemPos:=Selected list items(hList) GET LIST ITEM(hList;$vlItemPos;$vlItemRef;$vsItemText) $vlParentItemRef:=List item parent(hList;$vlItemRef) ` $vlParentItemRefgets 200
If the item "a - 1" is selected, the variable $vlParentItemRef gets 100, the item reference number of the item "a".
If the item "a" or "b" is selected, the variable $vlParentItemRef gets 0, because these items have no parent item.
See Also
GET LIST ITEM, List item position, SELECT LIST ITEMS BY REFERENCE, SET LIST ITEM.