xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Replicate()

Creates a character string by replicating an input string.

Syntax

Replicate( <cString>, <nCount> ) --> cReplicatedString

Arguments

<cString>
This parameter is the input string to replicate <nCount> times.
<nCount>
A numeric value indicating the number or times to replicate <cString>.

Return

The function returns a character string holding the input string <cString> <nCount> number of times.

Description

Replicate() provides a convenient way for creating an output string consisting of multiple copies of an input string.

A similar function is Space() which creates a character string consisting of blank space characters only.

Info

See also:PadC() | PadL() | PadR(), Space()
Category: Character functions
Source:rtl\replic.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows results of Replicate()

   PROCEDURE Main
      ? Replicate( "-", 17 )           // result: -----------------
      ? Replicate( "xHarbour ", 2 )    // result: xHarbour xHarbour
      ? Replicate( "!", 17 )           // result: !!!!!!!!!!!!!!!!!
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe