On Dec 23, 2011, at 9:23 AM, Robert Poland wrote: Hi,
The following script, cut from a larger script, isn't behaving as it did before. The Check Syntax command says;
-- Unused variables:
show window "Zoom copy" selection {58, 71} -- unused var: optionKeyDown -- set optionKeyDown to false -- reset property
Does it fail for others? Several scripts now exhibit this error.
Hi Robert,
Smile is trying to be helpful and tell you that you've defined a variable, but never made use of it. This functionality has been available for some time through Smile's 'validate' command, which reports both defined-but-unused and used-but-undefined variables. Apparently, Smile now provides that information at compile time. Either way, it's a terrific tool—embrace it!
As to your specifics, you can ignore Smile's feedback. That variable definition, though unused afterward, does serve a purpose. Clearly, you want the property reset to a default value.
But if it were me, I'd set it to the desired value at the beginning of the script run, rather than at the end. Like this: on run set optionKeyDown to false -- reset property main() beep end run IMO, it's a safer approach. And Smile would no longer complain about it. :-)
Stan C.
|