Jump to content
Sign in to follow this  
thepip3r

Opt("MustDeclareVars", 0) not entirely working?

Recommended Posts

thepip3r

I just reimaged my machine and went from XP to Vista. I'm not sure if my AutoIT version changed or not but when I tried to run my old projects, I'm getting massive undeclared variables notices and I have Opt("MustDeclareVars", 0) in the beginning of the projects. Can anyone pls assist?


My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites
Jos

You probably are missing several *constants.au3 include files.

Also Install SciTE4AutoIt3 and add this line to you script:

#AutoIt3Wrapper_Add_Constants=y

... and run it with F5. It will add all needed standard constants include files one time.

Jos

Edited by Jos

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

Share this post


Link to post
Share on other sites
thepip3r

@Jos: I added the #AutoIT3Wrapper_Add_Constants but not sure what you mean by the "F5" and am still getting errors:

@Volly: As requested:

[the project is rather big so I'm just including the first part of the file and some of the parts that are throwing the variable declaration error]

#AutoIt3Wrapper_Add_Constants=y

#include <GUIConstants.au3>
#include <file.au3>
#include <array.au3>
#include <Constants.au3>
#include <GuiEdit.au3>
#include <GuiListView.au3>
#include <MessageHandler.au3>
#RequireAdmin

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)  
Opt("GuiOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUICloseOnESC", 1)

; problem 1
$mainWindow =   GUICreate("RunAs Admin - " & @LogonDomain & "\" & @UserName, 400, 325, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

; problem 2
$mainFormStatusBar = GUICtrlCreateLabel ($mainFormStatusDefault,0,290,420,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

If FileExists($sSendTo & "\" & $sShortcutFile) Then 
              ; problem 3
    If FileDelete($sSendTo & "\" & $sShortcutFile) <> 1 Then errHandler(0, "Operation Failed", "Attempting to delete " & $sSendTo & "\" & $sShortcutFile & " failed.")
EndIf

On problem 1 and 2, the vars that are giving errors are the ones specified after the BitOr. In problem three, $sSendTo is the culprit. Again -- now sure why this is happening considering I have the Options sets that I do. Thanks so much for the help guys.

Edited by thepip3r

My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites
Jos

@Jos: I added the #AutoIT3Wrapper_Add_Constants but not sure what you mean by the "F5" and am still getting errors:

Open the script in SciTE and press F5 which will run the script from within the editor.

Jos


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

Share this post


Link to post
Share on other sites
thepip3r

wow very nice.... i'll have to look at that more in depth here in a sec but let me report the errors here real quick:

F:\RunAs Admin.au3(44,54) : WARNING: $Remote_ReceiverID_Name: possibly used before declaration.
    $iSent = _SendData($vText,$Remote_ReceiverID_Name)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(643,29) : WARNING: $CAFullPath: possibly used before declaration.
        GUICtrlSetData($CAFullPath,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(651,39) : WARNING: $CANickname: possibly used before declaration.
    Local $nick = GUICtrlRead($CANickname)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(653,40) : WARNING: $CAArguments: possibly used before declaration.
    Local $args = GUICtrlRead($CAArguments)
    ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(670,31) : WARNING: $progConfCustom: possibly used before declaration.
    If FileExists($progConfCustom)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(673,8) : ERROR: syntax error
    ElseIf
    ~~~~~~^
F:\RunAs Admin.au3(674,108) : ERROR: syntax error
        errHandler(100,"Error Locating File", "An error occurred while trying to locate " & $progConfCustom & ".")
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


~~~~~~~~~~^
F:\RunAs Admin.au3(677,68) : ERROR: syntax error
    $t = FileWriteLine($null, $nick & "," & $fp & "," & $args & @CRLF)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(678,18) : ERROR: syntax error
    If $t <> 1 Then errHandler
    ~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(678,124) : ERROR: syntax error
    If $t <> 1 Then errHandler(101,"Error Writing File", "An error occurred while trying to write to " & $progConfCustom & ".")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(699,28) : ERROR: syntax error
    $ub = Ubound($arrDelete)-1
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(701,32) : ERROR: syntax error
        If $arrDelete[$i] <> "" Then GUICtrlDelete
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(824,21) : WARNING: $about: possibly used before declaration.
    GUIDelete($about)
~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(924,11) : WARNING: $RSPC: possibly used before declaration.
    If $RSPC =
    ~~~~~~~~~^
F:\RunAs Admin.au3(928,25) : WARNING: $sSendTo: possibly used before declaration.
    If FileExists($sSendTo &
    ~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(928,47) : WARNING: $sShortcutFile: possibly used before declaration.
    If FileExists($sSendTo & "\" & $sShortcutFile)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(1016,18) : ERROR: $fp already declared as parameter
    Dim $newMenu,$fp,
    ~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(1016,38) : ERROR: $menu already declared as parameter
    Dim $newMenu,$fp,$file,$search,$menu,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(44,54) : ERROR: $Remote_ReceiverID_Name: undeclared global variable.
    $iSent = _SendData($vText,$Remote_ReceiverID_Name)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(327,43) : ERROR: __menuCustomDelete(): undefined function.
GUICtrlSetOnEvent(-1, "__menuCustomDelete")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(715,41) : ERROR: __menuCustomLinkDelete(): undefined function.
        __menuCustomLinkDelete($sSelectedIndex)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3 - 12 error(s), 9 warning(s)

[edit] :: After successfully doing what you suggested Jos, it alleviated "problem 1 and 2" but problem 3 still exists... it only flags at runtime though, not when the script is interpreted initally.

Edited by thepip3r

My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites
Jos

All you need to do is to double click on the line with the error in the Output pane and it will jump to the correct line in the script. ;)


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

Share this post


Link to post
Share on other sites
thepip3r

so for these two errors, I'm still at a loss as to why I would have to declare the vars??

F:\RunAs Admin.au3(928,25) : WARNING: $sSendTo: possibly used before declaration.
    If FileExists($sSendTo &
    ~~~~~~~~~~~~~~~~~~~~~~~^
F:\RunAs Admin.au3(928,47) : WARNING: $sShortcutFile: possibly used before declaration.
    If FileExists($sSendTo & "\" & $sShortcutFile)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

I've checked both lines and they are syntactically correct (as far as I can tell) yet, SciTE still sees it as wrong?? Also, is there a good document somewhere on interpreting these errors so I don't waste forum goers' time by posting inane questions about this in the futuer?? =P


My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites
Jos

It is AU3check that warns you about the fact that these lines are referring to a variable of which it cannot determine if this variable is defined before this line is executed.

Simple example:

Demo()
$a = $b 

Func Demo()
    Global $b =1
EndFunc

This really should be "to play it safe":

Global $b
Demo()
$a = $b 

Func Demo()
    $b =1
EndFunc
Edited by Jos

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

Share this post


Link to post
Share on other sites
Jos

There is so much more in this package to make a coders life easier... just open the helpfile(Ctrl+F1) when you have a spare minute. ;)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.