Consultor Eletrônico



Kbase P118019: 4GL/ABL: CLASS method does not correctly receive the passed parameter value when the parameter is th
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/1/2008
Status: Unverified

SYMPTOM(s):

4GL/ABL: CLASS method does not correctly receive the passed parameter value when the parameter is the return value of the REPLACE function.

Compiling test.cls and running test.p from the Procedure Editor demonstrates that the CLASS method testMethod() does not correctly receive the passed values. That is it does not receive the correct return values of the REPLACE function:
/* test.p */
DEFINE VARIABLE objTest AS CLASS Test NO-UNDO.
objTest = NEW Test().
MESSAGE
SKIP(1) "Passed:" REPLACE("abcde", "e", "T")
SKIP "Method receives:" objTest:testMethod(REPLACE("abcde", "e", "T"))
SKIP(1) "Passed:" REPLACE("abcde", "e", "TE")
SKIP "Method receives:" objTest:testMethod(REPLACE("abcde", "e", "TE"))
SKIP(1) "Passed:" REPLACE("abcde", "e", "TES")
SKIP "Method receives:" objTest:testMethod(REPLACE("abcde", "e", "TES"))
SKIP(1) "Passed:" REPLACE("abcde", "e", "TEST")
SKIP "Method receives:" objTest:testMethod(REPLACE("abcde", "e", "TEST"))
VIEW-AS ALERT-BOX.
DELETE OBJECT objTest.
/* test.cls */
CLASS test:
METHOD PUBLIC CHARACTER testMethod
( pcSomeChar AS CHARACTER ):
RETURN pcSomeChar.
END METHOD.
END CLASS.

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.1A

CAUSE:

Bug# OE00131513

FIX:

Upgrade to OpenEdge 10.1B or later. If upgrading to OpenEdge 10.1B or later is not feasible, a workaround is to invoke the REPLACE function in the calling procedure and pass the returned value as a CHARACTER variable. For example, modify the above test.p procedure along the following lines:
DEFINE VARIABLE objTest AS CLASS Test NO-UNDO.
DEFINE VARIABLE cTempVar AS CHARACTER EXTENT 4 NO-UNDO.
objTest = NEW Test().
ASSIGN
cTempVar[1] = REPLACE("abcde", "e", "T")
cTempVar[2] = REPLACE("abcde", "e", "TE")
cTempVar[3] = REPLACE("abcde", "e", "TES")
cTempVar[4] = REPLACE("abcde", "e", "TEST").
MESSAGE
SKIP(1) "Passed:" cTempVar[1]
SKIP "Method receives:" objTest:testMethod(cTempVar[1])
SKIP(1) "Passed:" cTempVar[2]
SKIP "Method receives:" objTest:testMethod(cTempVar[2])
SKIP(1) "Passed:" cTempVar[3]
SKIP "Method receives:" objTest:testMethod(cTempVar[3])
SKIP(1) "Passed:" cTempVar[4]
SKIP "Method receives:" objTest:testMethod(cTempVar[4])
VIEW-AS ALERT-BOX.
DELETE OBJECT objTest.