FUNCTIONS CORE

CharOne()

Remove duplicate adjacent characters from a string

Syntax

Signature
CharOne( [cDelete], cString ) --> cResult

Arguments

cDelete

cString

Example

CharOne.prg
PROCEDURE Main()

   Check( 'CharOne( "a  b   c" )             ', CharOne( "a  b   c" ), "a b c" )
   Check( 'CharOne( "bookkeeper" )           ', CharOne( "bookkeeper" ), "bokeper" )
   Check( 'CharOne( " ", "Hello   world!!" ) ', CharOne( " ", "Hello   world!!" ), "Hello world!!" )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

CharOne( "a  b   c" )             OK
CharOne( "bookkeeper" )           OK
CharOne( " ", "Hello   world!!" ) OK