Jump to content

Option MustDeclareVars Not working


Mercury049
 Share

Recommended Posts

Share your code. This will give you an error, even when MustDeclareVars is disabled...

Opt("MustDeclareVars" ,0)

MsgBox(0,"",$notDeclaredVar")

Helpfile:

If this option is used then all variables must be pre-declared with Dim, Local or Global before they can be used - removes the chance for misspelled variables causing bugs.

1 = Variables must be pre-declared

0 = Variables don't need to be pre-declared (default)

Link to comment
Share on other sites

My apologies for the delay in response. BUSY MONDAY! Thanks for all of the interest in helping me. I didn't want to put my full code up here as it's a LOT and a lot of stuff I wouldn't want public. So, I threw together a small snippet that should be simple enough to demonstrate. I also ran it and took a screen shot of the error so you guys wouldn't think I'm crazy. Though I fear I'll be smacked down in other areas. =) Thanks for any help.

#Include <SQLite.au3>

opt("MustDeclareVars", 0)


_SQLite_Startup()
_SQLite_open("testDB")

_SQLite_Exec(-1,"CREATE TABLE testingVars (test1,test2,test3);")
_SQlite_Exec(-1,"INSERT INTO testingVars(test1,test2,test3) VALUES ('value1','value2','value3');")
_SQlite_Query(-1,"SELECT * FROM testingVars;",$queryVars)
_SQLite_FetchData($queryVars,$varRows)

_SQLite_QueryFinalize($queryVars)
_SQLite_Close("testDB")
_SQLite_Shutdown()

The screenshot is attached to this listing.

post-39863-1222719235_thumb.jpg

Link to comment
Share on other sites

MustDeclareVars 1 means you have to declare variables before you assign values to them

if MustDeclareVars is 0 you can assign values to variables without declaring them but in both cases you can't use the vars until you've assigned them

Declaring:

Dim
Global
LocaloÝ÷ Ø,  ⮶­sbb33c¶×f#ÒgV÷C¶7G&ærgV÷C°¢b33c¶×f#Ó#0

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

So just to understand, by using that Opt I still have to call them out with a LOCAL or GLOBAL, but I don't have to give them a value?

i.e.

#Include <SQLite.au3>

Local $queryVars, $varRows

opt("MustDeclareVars", 0)

_SQLite_Startup()
_SQLite_open("testDB")

_SQLite_Exec(-1,"CREATE TABLE testingVars (test1,test2,test3);")
_SQlite_Exec(-1,"INSERT INTO testingVars(test1,test2,test3) VALUES ('value1','value2','value3');")
_SQlite_Query(-1,"SELECT * FROM testingVars;",$queryVars)
_SQLite_FetchData($queryVars,$varRows)

_SQLite_QueryFinalize($queryVars)
_SQLite_Close("testDB")
_SQLite_Shutdown()

I know that the code above works. My original thought on it was that using that Opt meant I didn't need the "LOCAL" call.

Thanks for your time everyone!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...