[OT] Why would it be a pain?

Dan Shafer revolutionary.dan at gmail.com
Thu Jun 22 14:47:25 EDT 2006


I think the real complication in the use of IT is less in its scoping than
in the fact that it's kind of a garbage variable that the system uses in
ways that aren't always predictable. Some operations return a value in IT
and others return a value in the result and, IIRC, sometimes you can get one
answser in IT and a different one in the result.

When I wrote my original book on HyperTalk, I said, among other things, "be
careful when using It in your scripts. Typically, you will use this special
variable when few, if any, commands appear between the time you put a value
into the variable and the time you need that variable."

As far as I know, the following Transcript commands place their results into
It (though there may be many others; this is the old HC list):

answer
ask
convert
get
read from file

(All variations of those as well.)

On 6/22/06, Jim Ault <JimAultWins at yahoo.com> wrote:
>
> 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
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Shafer, Information Product Consultant and Author
http://www.shafermedia.com
Get my book, "Revolution: Software at the Speed of Thought"
>From http://www.shafermediastore.com/tech_main.html



More information about the use-livecode mailing list