Functions and Directives

Function Replicate() Foundation

Replicates a character string a specified number of times.

Syntax
Replicate( <cString>, <nCount> )--> cReplicate
Parameters
<cString>
<cString> is the character string to replicate.
<nCount>
<nCount> is the number of times <cString> is replicated.
Return

Replicate() returns a character string having the length <nCount>multiplied by Len(<cString>). <cString> is included <nCount> times in the return value. The length of the return value is not limited in Xbase++. When <nCount> has the value zero, a null string ("") is returned.

Description

The character function Replicate() creates a character string in which a character or a character string is repeated. It is suitable for display of multiple copies of a single character or to write a specific set of characters repeatedly in the keyboard buffer. It is also used in the creation of PICTURE format clauses. Replicate(Chr(32),10) provides the same result as Space(10).

Examples
Replicate()

// The example shows various results of the function Replicate(). 

PROCEDURE Main 

   ? Replicate("_"       , 15)      // result: _______________ 
   ? Replicate("Xbase++ ", 2 )      // result: Xbase++ Xbase++ 
   ? Replicate("*"       , 15)      // result: *************** 

RETURN 
Create a PICTURE format using Replicate()
// In the example, a PICTURE formatting clause is 
// is created with Replicate(). 

PROCEDURE Main 
   LOCAL cString := Space(254) 

   CLS 
   @ 0,0 SAY "Input:" GET cString ; 
          PICTURE "@S60 " + Replicate("X",254) 
   READ 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.