variable checking has me mystified ...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
labrat
Posts: 32
Joined: Mon Dec 29, 2014 6:17 pm

variable checking has me mystified ...

Post by labrat » 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:

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
But that same code generates this compile time error when variable checking is turned on:

Code: Select all

button "Make Link": compilation error at line 2 (Expression: unquoted literal), char 43
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!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: variable checking has me mystified ...

Post by FourthWorld » Sun Feb 08, 2015 5:51 am

Link is a constant, and with variable checking on string constants must be quoted.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: variable checking has me mystified ...

Post by Klaus » Sun Feb 08, 2015 2:05 pm

Hi labrat,
Why in the world would LiveCode variable checking generate errors with valid code?
simply because the code is not 100% valid! :D
"Variable Checking" does not allow ANY syntax error, not even some tiny missing quotes.


Best

Klaus

Post Reply