Sign in to follow this  
Followers 0
Bokkie

Variable is

3 posts in this topic

#1 ·  Posted (edited)

I have this option defined as the first line of code in my script after any #includes.

Opt("MustDeclareVars", 1)

But the undeclared variable mmmmsg does not raise any compilation error to say it's not declared.

while 1
    local $msg = GuiGetMsg()
    local $control = ControlGetFocus($mainForm)
    PositionToEndOfLine($control)
    select
        case $mmmmsg = $GUI_EVENT_CLOSE
            ExitLoop

The documentation for Opt() states: 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.

What am I doing wrong?

Edited by Peter Hamilton-Scott

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I've no idea what was going on but it came right after I rebooted! :)

Edited by Peter Hamilton-Scott

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

When you run (AutoIt3) not compile this code:

Opt("MustDeclareVars", 1)
$mainForm = 1
local $msg = GuiGetMsg()
If 0 = 1 Then
    If $mmmmsg = $GUI_EVENT_CLOSE Then 
        $a = 1
    EndIf
EndIf

An error will be triggered with Opt("MustDeclareVars", 1) and runs fine with Opt("MustDeclareVars", 0)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0