Jump to content

Is the order is matter in AutoIt?


atzoref
 Share

Recommended Posts

Hi,

I see some scripts, and for example in some functions they uses some variables which declared in the main script

after the line of calling to the function.

So my question is if the order in the script is matter?

Thanks.

Edited by atzoref
Link to comment
Share on other sites

Yes, if you try to access a variable, before it is declared, you will get an error.

Global $1 = 1
Global $2 = 2
Global $3 = 3
_Test1()
Global $4 = 4
_Test2()
Global $5 = 5
Func _Test1()
MsgBox(0,0,$1 & $2 & $3)
EndFunc
Func _Test2()
MsgBox(0,0,$1 & $2 & $3 & $4 & $5)
EndFunc

EDIT:

But the position of any function you might create does not matter, they are read before execution of the script.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

maybe if you post workable script we can see, note that included UDF-s have in them declared variables so command 4 example

GUICreate("", 169, 68, 20, 20, $WS_POPUP)

will need

#include <WindowsConstants.au3>

that have $WS_POPUP declared in UDF

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Because I see a function like this:

GUICtrlSetOnEvent($ID, "Some Func")

it calls to function which use "X" variable

but this "X" variable declare just after thie line:

GUICtrlSetOnEvent($ID, "Some Func")

How can that be?

So move it to before that line if it causing problem.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...