Kbase P19892: How to strip a character from a text string
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  25/01/2005 |
|
Status: Unverified
GOAL:
How to strip an unwanted character from a text string.
GOAL:
For example if a comma "," is embedded in a text string and this needs removing. Use the INDEX function to find the position of the character and then build a new string around this position.
FIX:
DEF VAR a1 AS CHARACTER INITIAL "1234567890,".
DEF VAR a2 AS CHARACTER INITIAL "".
DEF VAR ipos AS INT.
ipos = INDEX(a1,",").
a2 = SUBSTRING(a1,1,ipos - 1) + SUBSTRING(a1,ipos + 1, LENGTH(a1) - ipos).
DISPLAY
ipos
a1 FORMAT "X(15)"
a2 FORMAT "X(15)".