variable checking has me mystified ...
Posted: Sun Feb 08, 2015 4:35 am
I used VB and VB.net for years. I always declared my variables. I've been learning LiveCode because I love the multi-platform support and I naturally turned on Variable Checking. But it has me completely mystified. For example,
This code works when variable checking is NOT active:
But that same code generates this compile time error when variable checking is turned on:
What's the deal? Why in the world would LiveCode variable checking generate errors with valid code? I've run into similar problems in other LC scripts. In my view, it really reduces the value of "variable checking" when valid code is flagged with non-existent errors. I never had these issues with the VB equivalent "Option Explicit" (which requires variables to be declared before they are used).
In my view, variable checking should just check to see if a variable has been previously declared PERIOD. But, it seems that LC somehow "hides" the fact that what appear to be reserved words (or constants) in the code are actually handled internally as variables. Hence it triggers errors based upon whether what appears to be a reserved word or constant is really an "imposter" (i.e., a variable disguised as a reserved word or system defined constant). I don't know. I am just speculating. But, all I know is that in VB, "option explicit" let me declare my variables, or warn me when I had not, and that was the end of it. I just don't understand variable checking and would appreciate some enlightenment.
Thanks!
This code works when variable checking is NOT active:
Code: Select all
on mouseUp
set the textStyle of the selectedChunk to link
set the linkText of the selectedChunk to "http://revolution.byu.edu/textfind/TextandFind.php"
end mouseUp
Code: Select all
button "Make Link": compilation error at line 2 (Expression: unquoted literal), char 43
In my view, variable checking should just check to see if a variable has been previously declared PERIOD. But, it seems that LC somehow "hides" the fact that what appear to be reserved words (or constants) in the code are actually handled internally as variables. Hence it triggers errors based upon whether what appears to be a reserved word or constant is really an "imposter" (i.e., a variable disguised as a reserved word or system defined constant). I don't know. I am just speculating. But, all I know is that in VB, "option explicit" let me declare my variables, or warn me when I had not, and that was the end of it. I just don't understand variable checking and would appreciate some enlightenment.
Thanks!