Sign in to follow this  
Followers 0
dufran3

Variable used without being declared

12 posts in this topic

The two variables that I'm using in my script are in these lines of code...

Getting error with $BS_DEFPUSHBUTTON

$Button_1 = GUICtrlCreateButton ("OK",  190, 60, 0, 0, $BS_DEFPUSHBUTTON)oÝ÷ Øg­¶)àzºè¯­MúBTCS³«­¢+Ù
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=MoÝ÷ Ø+«­éí(§¶¬r¸©´Z½ëayú%"§r[zÆ®¶­s`6æ6ÇVFRfÇC´wV6öç7FçG2æS2fwC° 6æ6ÇVFRfÇC´RæS2fwC° 6æ6ÇVFRfÇC´'&æS2fwC

Am I missing needed includes???

BTW, as a side note, the script executes fine when executing out of Scite, only get error after compiling into .exe

Share this post


Link to post
Share on other sites



Well...if I uncomment the following line...I get that error when running in Scite. Is it not compiling this file when compiling the .exe?

#include <GuiConstants.au3>

Share this post


Link to post
Share on other sites

Yes

Share this post


Link to post
Share on other sites

lol, why not? I tried including the entire path.

#include <C:\Program Files\AutoIt3\Include\GuiConstants.au3>

But still not working

Share this post


Link to post
Share on other sites

Beats me. I don't really have much to go on though.

So far, what I can see, your code is:

#include <GuiConstants.au3>
    #include <IE.au3>
    #include <Array.au3>
$Button_1 = GUICtrlCreateButton ("OK",  190, 60, 0, 0, $BS_DEFPUSHBUTTON)
Case $msg = $GUI_EVENT_CLOSE

But I'm pretty sure that's not your entire script. :rolleyes: *hint hint*

Share this post


Link to post
Share on other sites

Of course that isn't everything...:-) Here is more, hopefully it will help

$Main = GUICreate('System ID', 300, 100) 

    Opt("GUICoordMode",1)
    $CollectSystemID = GUICtrlCreateInput('',100,20,100)
    $SystemIDLabel = GUICtrlCreateLabel('System ID',30,23)
    $CollectModality = GUICtrlCreateCombo('',100,40,50)
    GUICtrlSetData(-1,"CR|CT|DR|DX|MG|MR|NM|OT|PT|RF|RG|US|XA")
    $ModalityLabel = GUICtrlCreateLabel('Modality',30,43)
    GLOBAL $SystemID = ''
    $Button_1 = GUICtrlCreateButton ("OK",  190, 60, 0, 0, $BS_DEFPUSHBUTTON)
    $Button_2 = GUICtrlCreateButton ("Exit", 245, 60, 0, 0)

    GUISetState ()
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Button_1
                GLOBAL $SystemID = GUICtrlRead($CollectSystemID)
                GLOBAL $Modality = GUICtrlRead($CollectModality)
                If $SystemID == '' Then
                    MsgBox(0,'System ID','The System ID is a required field')
                Else
                WinSetState('System ID','',@SW_HIDE)
                ExitLoop
                EndIf
            Case $msg = $Button_2
                Exit
        EndSelect
    Wend

Share this post


Link to post
Share on other sites

This works:

#include <GuiConstants.au3>
    #include <IE.au3>
    #include <Array.au3>


    $Main = GUICreate('System ID', 300, 100) 
    Opt("GUICoordMode",1)
    $CollectSystemID = GUICtrlCreateInput('',100,20,100)
    $SystemIDLabel = GUICtrlCreateLabel('System ID',30,23)
    $CollectModality = GUICtrlCreateCombo('',100,40,50)
    GUICtrlSetData(-1,"CR|CT|DR|DX|MG|MR|NM|OT|PT|RF|RG|US|XA")
    $ModalityLabel = GUICtrlCreateLabel('Modality',30,43)
    GLOBAL $SystemID = ''
    $Button_1 = GUICtrlCreateButton ("OK",  190, 60, 0, 0, $BS_DEFPUSHBUTTON)
    $Button_2 = GUICtrlCreateButton ("Exit", 245, 60, 0, 0)

    GUISetState ()
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Button_1
                GLOBAL $SystemID = GUICtrlRead($CollectSystemID)
                GLOBAL $Modality = GUICtrlRead($CollectModality)
                If $SystemID == '' Then
                    MsgBox(0,'System ID','The System ID is a required field')
                Else
                WinSetState('System ID','',@SW_HIDE)
                ExitLoop
                EndIf
            Case $msg = $Button_2
                Exit
        EndSelect
    Wend

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

negative, that does not work. I copied what you posted, and it worked in Scite. As soon as a compile it to an .exe, it doesn't work. That's when I get the errors.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Just uninstalled Autoit, re-downloaded, and re-installed. And I am still getting that error when compiling...someone help please!!!

Edit: Is it related to the new version of the compiler? This has only started happening since I updated....hrmm..

Edited by dufran3

Share this post


Link to post
Share on other sites

Should I just uninstall the new version, and re-install the old version to compile?

Share this post


Link to post
Share on other sites

lol, it worked, I can't believe it. It looks like there may be a problem with the new compiler. Here is what I have discovered.

autoit-v3.2.4.9-setup:

Error Compiling scripts when GUIConstants.au3 is included.

I looked at GUIConstants.au3 and it has been changed for what looks like organization...but doesn't seem to work properly.

autoit-v3.2.2.0-setup

Exact same script file, with GUIConstants.au3, and it compiles fine.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

!!!!!!!!!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!

Someone might want to look at the new structure of the GUIConstants.au3. I don't think it is referencing the includes correctly. All my errors were related to this file. I had to search for the two problem related variables in each of those includes, and instead of including GUIConstants.au3 I had to directly include the file the variable was located in. ex. GuiDefaultsEx.au3

Just so ya kno...

!!!!!!!!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!

Edit: Went to other computer, couldn't replicate issue. Easiest way to fix this for me is just not to use variables... sadly enough...$GUI_Event_Close == -3...Guess I will just use the numerical value as appose to the variable.

Edited by dufran3

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