finding shadowed globals when strict compilation is on

Mark Wieder mwieder at ahsoftware.net
Sat Apr 20 21:06:58 EDT 2013


Dr.-

Saturday, April 20, 2013, 4:40:56 PM, you wrote:

> I have a recurring problem that a variable name was apparently called
> global *somewhere* in my multitude of scripts (hundreds?).

> I then declare it local elsewhere, and strict compilation throws a
> tizzy, blocking everything, even though it isn't available in the
> local scope.

> Is there *any* way to find out the offending other variable when
> "local name shadows" ??

That's what strict compilation is supposed to do :-P A variable, once
it's used, *is* available in the "local" scope. It's always in memory
until it's deleted. So locally you could pop up the message box, type
"global yournamehere;delete yournamehere" and then compile your
script. But that would only be a temporary fix because you'd still
have a var name conflict.

What are you trying to accomplish? Use the variable name as a local
var and *not* as a global one?

It's a good idea to usse a naming convention and start your global var
names with a "g" prefix and *never* start local var names with "g"
(use a different prefix for local vars). Then you won't run into this
kind of conflict.

But anyway, in the script editor type control-F, then click the More
button that appears at the bottom. Change the scope to Stack Files and
you'll get a list of everwhere that var name is used.

-- 
-Mark Wieder
 mwieder at ahsoftware.net





More information about the use-livecode mailing list