There are a number of functions and methods for working with comma (or other character) separated lists in Progress 4GL.
NUM-ENTRIES Returns the number of entries in a list. You can optionally specify delimiter, comma is default
NUM-ENTRIES(string [, delimiter])
Using comma, the default delimiter:
DEFINE VARIABLE cList AS CHARACTER NO-UNDO.
cList = "Goodbye,cruel,world!".
DISPLAY NUM-ENTRIES(cList). //3
Using another delimiter, semilcolon:
DEFINE VARIABLE cList AS CHARACTER NO-UNDO.
cList = "Goodbye;cruel;world!".
DISPLAY NUM-ENTRIES(cList, ";"). //3
ENTRY - function - returns a specified entry in a list
As usual starting position is 1, not 0!
ENTRY( entry, list [, delimiter]).
DEFINE VARIABLE cList AS CHARACTER NO-UNDO.
cList = "Goodbye,cruel,world!".
DISPLAY ENTRY(2, cList). //cruel
ENTRY - method - assigning the value of a specified entry in a list
ENTRY( entry, list [, delimiter]) = value
DEFINE VARIABLE cList AS CHARACTER NO-UNDO.
cList = "Goodbye,cruel,world!".
ENTRY(1, cList) = "Hello".
ENTRY(2, cList) = "nice".
MESSAGE REPLACE(cList, ",", " ") VIEW-AS ALERT-BOX. //Hello nice world!
LOOKUP - check a list for a specific entry. Returns it's entry.
If the string isn't present in the list lookup will returns 0
LOOKUP(string, list [, delimiter])
DEFINE VARIABLE cList AS CHARACTER NO-UNDO.
cList = "Hello,nice,world!".
MESSAGE LOOKUP("nice", cList) VIEW-AS ALERT-BOX. //2
MESSAGE LOOKUP("cruel", cList) VIEW-AS ALERT-BOX. //0