Split text based on seperator

NathanB

New Member
I am building a query against a database table. One of the fields is a character-separated list of Sales Rep Codes (e.g. 2673~5524~1911).

In Crystal Reports I would use Split(OrderHed.SalesRepList,'~')[0] to get "2673", Split(OrderHed.SalesRepList,'~')[1] to get "5524" and Split(OrderHed.SalesRepList,'~')[2] to get "1911".

What is the equivalent expression in Progress4GL?

Thanks,

NB
 

TomBascom

Curmudgeon
You want the ENTRY( element, list, delimiter ) function. i.e.:

Code:
define variable repList as character no-undo initial "2673~~5524~~1911".
define variable n as integer no-undo.
define variable i as integer no-undo.

n = num-entries( repList, "~~" ).
do i = 1 to n:
  display ENTRY( i, repList, "~~" ).
  pause.
end.

Notes:

1) Progress uses "~" as an escape character. Thus the double tildes.
2) Progress starts enumerations with 1 rather than 0.
3) It is a good habit to call NUM-ENTRIES() once and assign the result to a variable rather than with every iteration of the loop.
4) The delimiter argument is optional. The default delimiter is a comma.
 
Top