repeating a string
Cubist at aol.com
Cubist at aol.com
Mon Mar 21 20:17:44 EST 2005
sez xbury.cs at clearstream.com
>On 21.03.2005 05:18:39 use-revolution-bounces wrote:
>>Sorry about the partial repeat - lappie issues...
>>
>>I can't for the life of me remember how to repeat a string, and of
>>course I can't find anything in the docs either.
>>
>>I could do "a"&"a"&"a", but I thought there was something like "A"*3
>>or such available.
>
>yes there is but you have to make it yourself ;)
>
>function stringRepeat str, reps
> repeat reps
> put str after nustr
> end repeat
> return nustr
>end stringRepeat
What would this function do if handed a non-integer, or completely
non-numeric, value for "reps"? Also, I am somewhat uncomfortable with the notion of
uninitialized variables. And I suspect that "put before" might actually be a
bit faster than "put after", albeit the actual time difference isn't likely to
be significant in *most* cases. All of which said...
function stringRepeat2 DerText, Repz
switch
case Repz is not a number
return "Bad number of repetitions (alphabetic)"
break
case Repz is not an integer
return "Bad number of repetitions (decimal)"
break
default
put "" into Rezult
repeat Repz
put DerText before Rezult
end repeat
return Rezult
end switch
end stringRepeat
Hope this helps...
More information about the use-livecode
mailing list