Sign in to follow this  
Followers 0
Jsung

Can someone explain this for me?

6 posts in this topic

$answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box and get you to type in some text. Run?")

If $answer = 7 Then

MsgBox(4096, "AutoIt", "OK. Bye!")

Exit

EndIf

$bLoop = 1

While $bLoop = 1

$text = InputBox("AutoIt Example", "Please type in the word ""autoit"" and click OK")

If @error = 1 Then

MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")

Else

If $text <> "autoit" Then

MsgBox(4096, "Error", "You typed in the wrong thing - try again!")

Else

$bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too :)

EndIf

EndIf

WEnd

MsgBox(4096,"AutoIt Example", "You typed in the correct word! Congrats.")

That was the scripting in one of the autoit examples. I understand

If $answer = 7 Then

MsgBox(4096, "AutoIt", "OK. Bye!")

Exit

EndIf

...that.

but i dont really know what

$bLoop

is

and im very confused about

@error

and also

If $text <> "autoit"

Does taht mean if the reply is not autoit, it will go to the "Then" section?

and what is

MsgBox (4086, <<<... )

ive never seen that flag before.

i think i get everything except that.

Share this post


Link to post
Share on other sites



Look in the HELP FILE!

Share this post


Link to post
Share on other sites

Does taht mean if the reply is not autoit, it will go to the "Then" section?

Ding ding ding, we have a winner. @ERROR is generally set to 1 when there is an error, otherwise its zero, its value only exists immediately after the function returning it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$bLoop

@error

If $text <> "autoit"

Does taht mean if the reply is not autoit, it will go to the "Then" section?

and what is

MsgBox (4086, <<<... )

ive never seen that flag before.

$bLoop is a variable. It's set to the value "1" before a loop is entered. The test to stay within the loop (forever?) is for $bLoop to be equal to 1. The if/else may eventually set $bLoop to 0 (notice it's not 1) to be able to exit the loop and continue moving on in the script.

@error is a flag that certain internal functions (and perhaps UDFs? - dunno, I'm new too) can set. Check the CHM "AutoIt Help" file that came with the installation for the return values of the InputBox function.

<> is a "not equal to" syntax for certain scripting/programming languages, most notably (for me) Visual Basic. I'm more used to != (being initially educated as a C++ programmer)...there's also "NE" and "not equal" in other scripting languages, so be prepared in the future. :)

The "4096" for the MsgBox function is the "flag", or type of message box that is to be used. I'm not entirely sure what 4096 refers to ("information box" or 'warning message", perhaps?), but I think it's also in the manual/help file.

-- edit -- Boy, I hope my silly questions aren't answered with as much cynicism being new. :)

Edited by BrendonKoz

Share this post


Link to post
Share on other sites

thanks for the help BrendonKonz... ive been around programming and programmers and things like that for years but ive never thought to learn it.... o.o

so "bLoop" isnt actually anything but just the name for the variable declared by "$" ?

and so, it ends up as the variable completing the loop until the value is 0 or a closing statement is given?

Share this post


Link to post
Share on other sites

thanks for the help BrendonKonz... ive been around programming and programmers and things like that for years but ive never thought to learn it.... o.o

so "bLoop" isnt actually anything but just the name for the variable declared by "$" ?

and so, it ends up as the variable completing the loop until the value is 0 or a closing statement is given?

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