|
|
|
| 12 February 2002 | Repeat() |
| Author | W.M. Hinsch (New Mexico Mark) |
| Action | Returns a string composed of specified character(s) repeated n times. |
| Syntax | Repeat (String, Integer) |
| Parameters | |
| Remarks | This is a quick way to repeat a character an exact number of times. The function may yield unpredictable results with some characters (like "@"). However, it will handle ASCII 31 - 126 with no problems. It will also handle some unusual characters like BELL (ASCII 7). |
| Returns | A string containing the provided character repeated n times. |
| Dependencies | None. |
| Examples |
Repeat("<*>",26) ?
Repeat("*",79) ?
Repeat("Hi There ",8) ?
Repeat("*ABC123* ",8) ?
Repeat("Hello ",32000) ?
Repeat("Test ",16) ?
Repeat(" |||| ",10) ?
Repeat(" " + Repeat("(o)",2),10) ?
Repeat(" > ",10) ?
Repeat(" \___/",10) ?
; Console displays
;<*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*>
;*******************************************************************************
;Hi There Hi There Hi There Hi There Hi There Hi There Hi There Hi There
;*ABC123* *ABC123* *ABC123* *ABC123* *ABC123* *ABC123* *ABC123* *ABC123*
;Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
; |||| |||| |||| |||| |||| |||| |||| |||| |||| ||||
; (o)(o) (o)(o) (o)(o) (o)(o) (o)(o) (o)(o) (o)(o) (o)(o) (o)(o) (o)(o)
; > > > > > > > > > >
; \___/ \___/ \___/ \___/ \___/ \___/ \___/ \___/ \___/ \___/
|
| Source |
FUNCTION Repeat ($str, $int)
;Syntax: Repeat(String, Integer)
;String = ASCII string
;Integer = Positive integer
DIM $i
$str=''+$str
$int=0+$int
IF ($int >= 0) AND ($int <= 32000/Len($str)) AND ($str <> '')
FOR $i = 1 TO $int
$repeat=$repeat+$str
NEXT
ELSE
$repeat=''
ENDIF
ENDFUNCTION ; - Repeat -
|
|
|
|