Hard code or portable code
Brian Yennie
briany at qldlearning.com
Thu Mar 4 02:46:43 EST 2004
> Yes , All hats up for you.
> Just a question, why when I write ...
> put function () into field x it doesn't replace the old contents of
> the field ?
Try this.
Put the following in your stack script:
function latestFields
local myVar
repeat with i=1 to (the number of flds)
put fld i after myVar
end repeat
return myVar
end latestFields
Now in a button script, do this:
on mouseUp
put latestFields() into last fld
end mouseUp
The function by being in the stack script becomes available to you
whenever you need it. You may want to adjust where it puts the results.
> Now to compare if I write
> on mouseUp
> repeat with x=1 to the number of flds
> put text of field x & return after y
> end repeat
> put y into fld 1
> end mouseUp
>
> what is the difference besides function or message, speed wise or
> something else ?
> thanks , hershrev
>
Functions and handlers (functions start with "function", handlers with
"on") should execute at about the same speed, both very fast unless you
are really counting your milliseconds. The convenience of writing a
function rather than putting the code into your button's mouseUp
handler is that you can reuse the function and call if from various
other places.
HTH,
Brian
More information about the use-livecode
mailing list