Replicate()

This function lets you create a string composed of multiple copies of another string.

Usage

cNewString = REPLICATE( cString, nTimes )

Parameter

Value

Meaning

cString

Character

The string to be repeated to produce the result.

nTimes

Numeric

The number of times to repeat cString.

cNewString

Character

A string consisting of nTimes copies of cString.


REPLICATE() is handy for allowing you to use proportional fonts for input without ending up with too many characters. By specifying an InputMask (PICTURE clause in 2.x) of REPLICATE("X", LEN(<field>)), the user can't enter more characters than the field holds.In the little-known-facts department, you can pass an entire string to REPLICATE(), not just a single character. We suspect many experienced Xbase programmers don't realize this.

Example

? REPLICATE("X", 30)  && Returns a string of 30 X's
? REPLICATE("Fox", 3) && Returns "FoxFoxFox"

See Also

ChrTran(), InputMask, Space(), StrTran(), Stuff()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .