[OT] Why would it be a pain?

Jim Ault JimAultWins at yahoo.com
Thu Jun 22 13:44:59 EDT 2006


On 6/22/06 10:15 AM, "HyperChris at aol.com" <HyperChris at aol.com> wrote:

> My beef with IT is that IT isn't defined as a global variable by default. For
> example, if you need a quick file path and type ...
>     answer file ""
> ... you can't get your path unless you previously did this ...
>     global it
> In HC that was done by default which I found to be very handy. And that is
> all I have to say about IT.

I don't remember 'it' as being global by default in HCard.

The downside for using 'it' as a global is that any handler in any stack or
message path could affect that value.  In particular,
 the value of 'global it' is set in your handler,
then you navigate to another card,
and thus you may have triggered 'on closecard', 'on opencard', 'on
openstack', etc.

Of course, 'it' will be a local only, unless the script or handler declares
 global it
so any scripts you do not control will not regard 'it' as a global, such as
library front/back scripts, plugins.

Try card script = global it, get "huckleberry"
then have the stack script use 'it' as normal, 'it' = empty

This is normal variable scoping in Rev, and I think HCard.



Jim Ault
Las Vegas





More information about the use-livecode mailing list