Replace the TEXT Red with the TEXT Blue

AntonyNgorora7AntonyNgorora7 Member Posts: 18
These are the functions I have so far, but the word red will not convert to blue.

Custom Description - OnValidate()
//-- Validation for Custom Description
IF ("Custom Description" = UPPERCASE('RED')) THEN
fConvertCustomDescription("Custom Description", 'RED', 'BLUE');
IF ("Custom Description" = LOWERCASE('red')) THEN
fConvertCustomDescription("Custom Description", 'red', 'blue');

LOCAL fConvertCustomDescription(cDescription : Text[50];cRed : Text[50];cBlue : Text[50]) NewOutput : Text[50]
//-- fValidateCustomDescription
Pos := STRPOS(cDescription, cRed);
WHILE Pos > 0 DO //Original: WHILE Pos > 0 DO
BEGIN
cDescription := DELSTR(cDescription, Pos, STRLEN(cRed));
cDescription := INSSTR(cDescription, cBlue, Pos);
Pos := 0;
NewOutput := cDescription;
IF Pos = 0 THEN
EXIT(NewOutput);
END;

I tested it, it seems logically correct, but it won't convert the entered text red to blue.

Comments

  • CyberghostCyberghost Member Posts: 46
    why bother with the second function?

    Custom Description - OnValidate()
    //-- Validation for Custom Description
    IF ("Custom Description" = UPPERCASE('RED')) THEN
    "Custom Description" := 'BLUE';
    "When you eliminate the impossible, whatever remains, however improbable, must be the truth" - Sherlock Holmes

    "God and developers are in a constant battle. Developments to make their applications more idiot-proof, and God to produce bigger idiots!"
  • AntonyNgorora7AntonyNgorora7 Member Posts: 18
    Thank you so much. It worked. The second function actually doesn't serve much of a purpose. I am really grateful.
Sign In or Register to comment.