can't create a variable with that name

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: can't create a variable with that name

Post by Mag » Wed Mar 13, 2013 6:12 pm

Code: Select all

on menuPick pWhich
   switch pWhich
      case "Help"
         put "http://www.test.com/" into theLink
         launch URL theLink
         break
      case "About"
         go to stack "About This App"
         break
   end switch
end menuPick
put the explicitVariables
false
Is the Strict Compilation Mode option in the Script Editor pane of the preferences window turned off?
Yes
Do you use any plug-ins that don't come with the original LiveCode installation?
Usually I use MERG plugins, in this project to date not
Tanks!
Attachments
Screen Shot 2013-03-13 at 18.10.23.png

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: can't create a variable with that name

Post by Mark » Wed Mar 13, 2013 6:27 pm

Hi,

Your screen shot shows that strict compile mode is turned on! Please, turn it off and let me know if the problem persists.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: can't create a variable with that name

Post by Mag » Wed Mar 13, 2013 6:37 pm

Mark wrote:Hi,

Your screen shot shows that strict compile mode is turned on! Please, turn it off and let me know if the problem persists.

Kind regards,

Mark
When disabled strict compilation mode the problem seems disappaired.
No errors occurred
Maybe this option was turned on by Menu Builder... I don't know. Thank you so much Mark!

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: can't create a variable with that name

Post by MaxV » Wed Jun 05, 2013 9:29 am

Even if it's an old post, I encountered the same problem and I discovered this:
if you set in the Editor menu the Variable Checking on, you can't set new variables anymore and get can't create a variable with that name error.

I hope this could help beginners like me.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: can't create a variable with that name

Post by Mark » Wed Jun 05, 2013 9:41 am

Hi Max,

If Variable Checking is turned on, you are supposed to declare all variables. If you do this, you can still create new variables. If you turn on variable checking and haven't declared all variables on your scripts, you will get the same error, even though you'd think that you already created those variables. The error means that the compiler can't create the variable and has to abort the compilation. Here's an example of declaring a variable:

Code: Select all

local myVar

on mouseUp
  put 0 into myVar
end mouseUp
Instead of local, you can also use global or constant, depending on your needs. My book has a few sections about this ;-)

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: can't create a variable with that name

Post by MaxV » Thu Jun 06, 2013 10:49 am

Hi Mark,
I suggest you to restyle or check your site, I tried to download your "Split and recover" program, but I didn't succeed.
Moreover the sharing bar in the bottom has some missing images.
Is your book sent also in Europe, Italy?
If you restyle your site, many people will buy it. ;-)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: can't create a variable with that name

Post by Mark » Thu Jun 06, 2013 11:01 am

Hi,

What do you mean, didn't succeed? Did you get an error message or couldn't you find it or something else? Actually, this is pretty much off-topic, so I think it is better to use the contact form on Economy-x-Talk's website to report any problems with the website.

I'm so busy selling the book, that I have no time to fix the site ;-)

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply