repeat string: how ?
Ken Ray
kray at sonsothunder.com
Tue Nov 19 23:56:00 EST 2002
> Ken,
>
> Some remarks, if I may ...
>
> *) Your script asumes all arguments p1, p2 and p3 are filled when
InitContainer
> is called.
Actually, when I originally wrote it, I was not counting on having p1, p2
and p3 filled, but I failed to change the lines that said "put p1 into
pStartNum" to "if p1 is not empty then put p1 into pStartNum. The function
should have been:
function InitContainer pKind,pCount,p1,p2,p3
if pCount<=0 then return("")
if pCount= "" then return "Invalid number of arguments!"
put 1 into tNumSteps
put 1 into pStartNum
put cr into tSeparator
switch pKind
case "n"
if p1 is not empty then put p1 into pStartNum
if p2 is not empty then put p2 into tNumSteps
if p3 is not empty then put p3 into tSeparator
break
case "s"
put p1 into tString
if p2 is not empty then put p2 into tSeparator
break
end switch
put "" into tResult
set the lineDel to tSeparator
repeat with x = pStartNum to (pStartNum+pCount) step tNumSteps
if pKind = "n" then put x into line x of tResult
if pKind = "s" then put tString into line x of tResult
end repeat
return tResult
end InitContainer
In this case, the only things necessary are pKind and pCount (for numbers)
and pKind, pCount and p1 (for strings).
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list