Compile error with sample code

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jfgilbert
Posts: 2
Joined: Fri May 16, 2014 2:09 am

Compile error with sample code

Post by jfgilbert » Fri May 16, 2014 2:25 am

I am trying to use the standard script to connect to a MySQL database, but I am now getting a compiler error when trying to assign values to the database variables:

-- set up the connection parameters - edit these to suit your database
put "127.0.0.1" into tDatabaseAddress
Gives me this error:
button "Connect": compilation error at line 6 (Chunk: can't create a variable with that name (explicitVariables?) near "tDatabaseAddress", char 30

I have tried localhost or other IP addresses, it gets the same error.
The strange thing is that it used to work, and earlier stack that use that code work fine as long as I don't recompile.
I have taken the code straight from the SQL connect example and I get the same error.
I have re-downloaded and re-installed Livecode. It makes no difference.
If I comment this line out, I get the same error on the next line with tDatabaseName.
It seems like I am missing some definitions?
Thank you for any ideas.

icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am

Re: Compile error with sample code

Post by icouto » Fri May 16, 2014 2:32 am

"Explicit Variables" is a compiler setting in LiveCode, that requires you to explicitly DECLARE any local variables before using them. This is something you can turn on/off in the LiveCode Preferences (Script Editor pane), and is usually titled "Strict Compilation Mode". It can be very useful to have it on, as it helps avoid bugs that are incredibly hard to track down - like misspelt local variable names...

If you have "strict compilation mode" turned on, you simply have to declare your local variables first:

Code: Select all

local tDatabaseAddress
put "127.0.0.1" into tDatabaseAddress
I hope this helps.

jfgilbert
Posts: 2
Joined: Fri May 16, 2014 2:09 am

Re: Compile error with sample code

Post by jfgilbert » Fri May 16, 2014 3:00 am

Great, thank you. The setting must have been reset when I upgraded to 6.6.

Post Reply