Declaring Variables

Jan Schenkel janschenkel at yahoo.com
Mon Nov 27 15:35:57 CST 2006


--- LunchnMeets at aol.com wrote:
> Hi,
> 
> I've seen references to declaring or initializing
> variables. How and why 
> would I do that?
> 
> Joe
> 

Hi Joe,

Globval and script-local variables need to be
declared, or you can't use them as such - the compiler
will assume you're working with a temporary variable
by the same name, and may even decide that the default
value of that variable is the same as the name of the
variable.
Declaring all your variables is good practice and
helps you write software with less bugs: when you turn
on 'variable checking' the compiler will not accept a
script where any variable hasn't been previously
declared.
Some people feel it gets in the way of their scripting
style, and that's why it's nice to have it as an
option rather than rigorously enforced by the
compiler.
Personally, I don't declare temporary variables in
one-off scripts, but I do declare them in libraries
and production software. I'm sure I'm not the only Rev
user who has discovered and consequently fixed bugs
that way before sending the software out the door.

Just my two cents,

Jan Schenkel.

Quartam Reports for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com



More information about the use-livecode mailing list