Consultor Eletrônico



Kbase P115408: Error 2920 with the '&' literal in the SUBSTITUTE function?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/04/2006
Status: Unverified

SYMPTOM(s):

Error 2920 when trying to use a literal '&' ampersand with the SUBSTITUTE function?

Invalid character '' following '&' in SUBSTITUTE. (2920)

Escaping & with the substitute function results in error 2920. For example:

MESSAGE SUBSTITUTE("&1 ~& &2", "Ox", "Plough") SKIP
VIEW-AS ALERT-BOX.

FIX:


Use the double ampersand to force Progress to read the character literally:

DEFINE VARIABLE cvar1 AS CHARACTER INIT "Ox" NO-UNDO.
DEFINE VARIABLE cvar2 AS CHARACTER INIT "Plough" NO-UNDO.
DEFINE VARIABLE cString AS CHARACTER NO-UNDO.
cString = "&1 ~&& &2".
MESSAGE cString SKIP
SUBSTITUTE(cString, cvar1, cvar2) SKIP
SUBSTITUTE("&1 ~&& &2", cvar1, cvar2) SKIP
VIEW-AS ALERT-BOX.