CREATE

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()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net