FUNCTIONS CORE

Expand()

Insert characters between all characters of a string

Syntax

Signature
Expand( cString, [nCount], [xChar] ) --> cResult

Arguments

cString

nCount

xChar

Example

Expand.prg
PROCEDURE Main()

   Check( 'Expand( "123456" )         ', Expand( "123456" ), "1 2 3 4 5 6" )
   Check( 'Expand( "123456", 2 )      ', Expand( "123456", 2 ), "1  2  3  4  5  6" )
   Check( 'Expand( "123456", "." )    ', Expand( "123456", "." ), "1.2.3.4.5.6" )
   Check( 'Expand( "123456", 2, "." ) ', Expand( "123456", 2, "." ), "1..2..3..4..5..6" )
   Check( 'Expand( "A" )              ', Expand( "A" ), "A" )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

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

RETURN

Output

Expand( "123456" )         OK
Expand( "123456", 2 )      OK
Expand( "123456", "." )    OK
Expand( "123456", 2, "." ) OK
Expand( "A" )              OK