Work with lists
- Last Updated: January 22, 2026
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
- Sales quotas for 12 months
- The department names in your company
- The names of the 12 months of the year
Define a list
A list is a string with substrings, each separated by a separator character. A comma is the default separator.
The following example code shows two examples of list variables. You do not need to initialize a list variable when it is defined, but it must have items in it in order for you to work with it.
|
Access a value in a list
ABL provides functions to access and manipulate the items in a list. These functions allow you to:
- Locate the position of an item in the list (
LOOKUPfunction). - Extract a value from a particular position in the list (
ENTRYfunction). - Find out how many items are in the list (
NUM-ENTRIESfunction). - Set a particular item in a list to a value (
ENTRYstatement).
Look up an item in a list
Use the LOOKUP function to determine whether a specific item is
in a list. The LOOKUP function returns 0 if the
item is not in the list; otherwise, it returns an integer value of the item's
position in the list.
The syntax for the LOOKUP function is:
|
position- Returns an INTEGER value of the position of expression in list. If not found, then position is set to 0.
expression- A character expression to search for in list.
list-
A CHARACTER variable that contains a comma-separated list of items.
Example: Use LOOKUP with a list
In the following example code, a list called cMonths is defined, which contain the months of the year. expr is the expression to search for in the list and is
set to "Sep".
|
The following output is produced from running the code. Note that the position is set to 9, because "Sep" occurs in the ninth position in the list.
|
Extract a value from a list
Use the ENTRY function to return an entry from a list based on an integer position.
|
The following example code extracts address data from a comma-separated list.
|
The following output is produced from running the code.
|
Determine how many entries are in a list
Use the NUM-ENTRIES function to return how many items are in a
list. NUM-ENTRIES is useful when you want to
process items in the list in a loop. The value of NUM-ENTRIES tells you the number of iterations you need to do.
The example code uses NUM-ENTRIES to determine the number of times
to iterate in the REPEAT block.
|
Running the code produces the following output:
|
Set a value in a list
You can substitute a value in a list with a different value by using the ENTRY statement. The syntax for the
ENTRY statement is:
|
position- An integer value that corresponds to the position of a character string in a list.
list- A list of character strings separated with a character delimiter.
expr- A character value that replaces the item in the list at the specified position.
The following example code substitutes character strings in French.
|
Running the code produces the following output:
|
|