Consultor Eletrônico



Kbase P124727: How to get the position of the target string within the source string using ABL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   03/07/2007
Status: Unverified

GOAL:

How to get the position of the target string within the source string using ABL

GOAL:

How to get the position of a specific character in a string

FACT(s) (Environment):

All Supported Operating Systems
Progress/OpenEdge Versions
WebSpeed Versions

FIX:

Use INDEX function.

Sample code:


For this example, you must enter 1, 2, 3, 4, or 5. The INDEX function checks if the digit exists in the string "12345". DEFINE VARIABLE x AS CHARACTER FORMAT "9"
LABEL "Enter a digit between 1 and 5".
DEFINE VARIABLE show AS CHARACTER FORMAT "x(5)" EXTENT 5 LABEL "Literal"
INITIAL["One", "Two", "Three", "Four", "Five"].

REPEAT:
SET x AUTO-RETURN.
IF INDEX("12345",x) = 0 THEN DO:
MESSAGE "Digit must be 1,2,3,4, or 5. Try again.".
UNDO, RETRY.
END.
ELSE DISPLAY show[INTEGER(x)].
END.