Jump to content

Recommended Posts

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
Posted (edited)

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

Edited by Peter Hamilton-Scott
  • Developers
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

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