common code patterns

Alex Tweedly alex at tweedly.net
Thu Aug 10 19:40:23 EDT 2017


Sticking with that style, why not do

repeat with i=1 to paramcount()-1
             put param(i)&"," after theValue
end repeat
put param(paramcount()) after theValue

Shorter, faster, and just plain tidier :-)


or, to change style, is there a reason not to do

put param(1) into isLeft
put param(2) into isTop
etc.

This always has fewer lines (i.e. the same number of lines as the 
"recombine" part), and removes the loop completely.

-- Alex.



On 10/08/2017 21:18, Malte Pfaff-Brill via use-livecode wrote:
> Hi Monte,
>
> What I do way too often is combining all parameters of a function in a string and then split them up again as needed e.g.:
>
>
> repeat with i=1 to paramcount()
> 	if i<paramcount() then
>          	put param(i)&"," after theValue
>           else
>              put param(i) after theValue
>           end if
> end repeat
>
> — specific code follows:
>
>   put item 1 of theValue into isLeft
>   put item 2 of theValue into isTop
>   put item 3 of theValue into isRight
>   put item 4 of theValue into isBottom
>
>
> As this allows me to pass most variants to the function:
>
> myFunction(10,20,30,40)
>
> Or
>
> myFunction(the rect of grc „myGraphic"
> myFunction(the loc of me,10,
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list