DEV Community

loading...

Discussion on: Daily Challenge #259 - Duplicate Encoder

Collapse
patricktingen profile image
Patrick Tingen • Edited
/* Progress 4GL Daily Challenge #259
*/
FUNCTION dupDecode RETURNS CHARACTER (pcString AS CHARACTER):
  DEFINE VARIABLE i AS INTEGER NO-UNDO.
  DO i = 1 TO LENGTH(pcString):
    pcString = REPLACE( pcString
                      , SUBSTRING(pcString,i,1)
                      , STRING(NUM-ENTRIES(pcString,SUBSTRING(pcString,i,1)) = 2,'(/)')
                      ).
  END.
  RETURN pcString.
END FUNCTION.

MESSAGE dupDecode('Success')
  VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.