common code patterns

Paul Dupuis paul at
Thu Aug 10 10:57:23 EDT 2017

On 8/10/2017 6:01 AM, Monte Goulding via use-livecode wrote:
> Hi Folks
> I’m looking for a few common code patterns that you find yourselves writing often but aren’t well suited to reusable handlers. So snippets of code or common ways that events are handled together in a script for a certain task.
> Cheers
> Monte

I am not sure I get exactly what you are looking for, but I find myself
rewriting very similar code over and over again in resizeStack and
resizeControl handlers

on resizeStack x,y
-- what I want to do is modify part of an object rect, something like:
-- set rect of btn X to rect of btn X but with new right of y-10
-- and end up writing
set rect of btn X to (item 1 of rect of btn X,item 2 of rect of btn X,
y-10, item 4 of rect of btn X)
end resizeStack

Sometimes I just want to add to 1 or more items in the rect, sometime
replace the values. Using top,left,etc, MOVES the object. You have to
use the rect to resize. Of course, I could write functions (and have) to
do this. There are a lot of approaches people take with function, from
general to specific.

set rect of btn X to resizeRectRight(btn X,y-10)

A clean way to do this would be nice. Say something like instead of:
set the right of btn X to y-10 -- moves button
modify the right of btn X to y-10 -- resizes button

More information about the Use-livecode mailing list