Difference between revisions of "Documentation/How Tos/Calc: REPT function"

From Apache OpenOffice Wiki
Jump to: navigation, search
(See also:)
(Difference between REPT and CONCATENATE)
Line 9: Line 9:
  
 
=== Example: ===
 
=== Example: ===
<tt>'''REPT("ha"; 3)'''</tt>
+
* <tt>'''REPT("ha"; 3)'''</tt>
: returns <tt>'''hahaha'''</tt>.
+
:: returns <tt>'''hahaha'''</tt>.
 
+
* <tt>'''REPT(ROUND(RAND()*10); 3)'''</tt>
 +
:: returns <tt>'''nnn'''</tt> where <tt>'''n'''</tt> is a random digit repeated three times, while:
 +
::: <tt>'''CONCATENATE(ROUND(RAND()*10); ROUND(RAND()*10); ROUND(RAND()*10))'''</tt>
 +
:: returns <tt>'''xyz'''</tt> where <tt>'''x'''</tt>,  <tt>'''y'''</tt>, <tt>'''z'''</tt> are three randomly independent digits.
 +
 
 
=== See also: ===
 
=== See also: ===
 
'''[[Documentation/How_Tos/Calc: CONCATENATE function|CONCATENATE]]'''
 
'''[[Documentation/How_Tos/Calc: CONCATENATE function|CONCATENATE]]'''

Revision as of 10:30, 9 December 2008


REPT

returns a text string comprised of copies of another text string.

Syntax:

REPT(text; number)

returns number copies of text, joined together.

Example:

  • REPT("ha"; 3)
returns hahaha.
  • REPT(ROUND(RAND()*10); 3)
returns nnn where n is a random digit repeated three times, while:
CONCATENATE(ROUND(RAND()*10); ROUND(RAND()*10); ROUND(RAND()*10))
returns xyz where x, y, z are three randomly independent digits.

See also:

CONCATENATE

Text functions

Functions listed alphabetically, Functions listed by category

Personal tools