Progress
Language Reference


NUM-ENTRIES Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns the number of items in a list.

SYNTAX

NUM-ENTRIES ( list [ , character ] ) 

list

A list of strings—an entry list. (See the ENTRY Function reference entry.) NUM-ENTRIES returns the number of elements in the list. Specifically, NUM-ENTRIES returns the number of delimiters plus 1, and it returns 0 if list equals double quotes ("").

character

A delimiter you define for the list. The default is a comma (,). This allows functions to operate on non-comma-separated lists. If you use an alphabetic character, this delimiter is case sensitive.

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 i=1 TO 5, works fine here.

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

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

r-n-ent2.p
DEFINE VARIABLE i AS INTEGER.
REPEAT i=1 TO NUM-ENTRIES(PROPATH):
  DISPLAY ENTRY(i,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.
  sentence  = "This sentence would be seven words long "
      + "if it were six words shorter".
DISPLAY NUM-ENTRIES(sentence," "). 

NOTE

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

SEE ALSO

ENTRY Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095