PreviousNextIndex

NUM-ENTRIES function

Returns the number of elements in a list of character strings as an INTEGER value.

Syntax

NUM-ENTRIES ( list [ , character ] ) 

list
character
Examples

This procedure uses NUM-ENTRIES and ENTRY to loop through a list of regions and display them, one per line. Since there are obviously five regions, the REPEAT statement, REPEAT ix = 1 TO 5, works fine here.

r-n-ent1.p
DEFINE VARIABLE ix      AS INTEGER   NO-UNDO. 
DEFINE VARIABLE regions AS CHARACTER NO-UNDO  
  INITIAL "Northeast,Southest,Midwest,Northwest,Southwest". 
REPEAT ix = 1 TO NUM-ENTRIES(regions): 
  DISPLAY ENTRY(ix, regions) FORMAT "x(12)". 
END. 

In the following example, PROPATH is a comma-separated list of unknown length:

r-n-ent2.p
DEFINE VARIABLE ix AS INTEGER NO-UNDO. 
REPEAT ix = 1 TO NUM-ENTRIES(PROPATH): 
  DISPLAY ENTRY(ix, PROPATH) FORMAT "x(64)". 
END. 

This procedure uses NUM-ENTRIES to loop through the PROPATH (a comma-separated list of directory paths) and print the directories, one per line.

This example uses a list that does not use commas as a delimiter. This procedure returns a value of 13:

r-n-ent3.p
DEFINE VARIABLE sentence AS CHARACTER NO-UNDO INITIAL 
  "This sentence would be seven words long if it were six words shorter". 
DISPLAY NUM-ENTRIES(sentence," "). 

Note

The NUM-ENTRIES function is multi-byte enabled. The specified list can contain entries that have multi-byte characters and the character delimiter can be a multi-byte character.

See also

ENTRY function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex