Constant command
Robert Brenstein
rjb at robelko.com
Thu Oct 14 18:54:33 EDT 2010
On 14.10.10 at 13:50 -0400 DunbarX at aol.com apparently wrote:
>Mark.
>
>But script local variables do all that as well, no? It isn't a big deal,
>but except for the fact that these can replace predefined constants (a feature
>less available in LiveCode than in HC, especially as regards build-in
>functions) I still don't see the point.
>
As others said, this is a matter of programming style. What I often
use script-wide constants for is for names of objects user interacts
with. For example, on a card level, I may have several handlers that
refer to a button or a field (for example, resizestack, scripts that
handle GUI). Using constant is just convenient. Using script locals
requires having a series of assignments in some handler, one that
will be 100% sure called before any other handlers, like preopencard.
List of constant on top of the script is just cleaner and
initialization is done at compile time, so the order of handlers is
irrelevant. And if you ever had to change a name of an object when
your card script has 15 or 20 references to that object, the
advantage of using a constant as opposed to using literal names
becomes quite obvious.
robert
More information about the use-livecode
mailing list