Sign in to follow this  
Followers 0
jonez34

If then statements

19 posts in this topic

I tried searching the forums for this question as I am sure someone has asked this but I didn't have enough charachthers for the search.

Anyway, I am very new to this (2 hours in fact) and am wondering how do I do an if statment where a Yes anwser will go somewhere an No will quit the script.

I'm thinking of something like

If MsgBox(4,"Blah","Blah") = <this is were I need help>

I need the yes to go to either another line in the script or call another au3 file (haven't decided yet) and the NO to just exit. I think that I need an Else statement but everything that I try gives me an error.

Also since I would like to know, whats the equivilent of the batch files GOTO command in autoit?

I am really looking forward to the anwser as this is a really cool way of doing things.

Share this post


Link to post
Share on other sites



I tried searching the forums for this question as I am sure someone has asked this but I didn't have enough charachthers for the search.

Anyway, I am very new to this (2 hours in fact) and am wondering how do I do an if statment where a Yes anwser will go somewhere an No will quit the script.

I'm thinking of something like

If MsgBox(4,"Blah","Blah") = <this is were I need help>

I need the yes to go to either another line in the script or call another au3 file (haven't decided yet) and the NO to just exit. I think that I need an Else statement but everything that I try gives me an error.

Also since I would like to know, whats the equivilent of the batch files GOTO command in autoit?

I am really looking forward to the anwser as this is a really cool way of doing things.

Button Pressed Return Value

OK 1

CANCEL 2

ABORT 3

RETRY 4

IGNORE 5

YES 6

NO 7

TRY AGAIN ** 10

CONTINUE ** 11

so

If MsgBox(4,"Blah","Blah") = 6 then
     ; yes
Else
    ; No
EndIF

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

Share this post


Link to post
Share on other sites

O.k. so below is the script that I am trying to get done.

If MsgBox (4,"Question","Do you have a zip program installed?") = 6 Then MsgBox (0,"what","what")

Else Exit

EndIf

I always get an error when I run it. Also instead of the MsgBox of what and what how would I get it to go to either another line in the script (line 21 for example) or call another au3 file?

Share this post


Link to post
Share on other sites

O.k. so below is the script that I am trying to get done.

If MsgBox (4,"Question","Do you have a zip program installed?") = 6 Then MsgBox (0,"what","what")

Else Exit

EndIf

I always get an error when I run it. Also instead of the MsgBox of what and what how would I get it to go to either another line in the script (line 21 for example) or call another au3 file?

That is because you do not use the proper syntax... look at the helpfile to see the options...

If MsgBox (4,"Question","Do you have a zip program installed?") = 6 Then 
   MsgBox (0,"what","what")
Else 
   Exit
EndIf

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thank you JdeB. I tried the help file but it is a little to vague sometimes.

Now above the posts says that I can use the Loop command. How does the loop command send the script to another line in the code?

Edited by jonez34

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thank you JdeB. I tried the help file but it is a little to vague sometimes.

Nah... there is a difference between vague and not understanding .... :P

Thank you JdeB. I tried the help file but it is a little to vague sometimes.

Now above the posts says that I can use the Loop command. How does the loop command send the script to another line in the code?

I am sure BALA will be happy to elaborate on that .... Edited by JdeB

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

Share this post


Link to post
Share on other sites

Nah... there is a difference between vague and not understanding .... :D

I am sue BALA will be happy to elaborate on that ....

I'm not quite sure if that's a compliment or insult. So I'll just stare.... :P


[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Anyways, I'm quite into NT Batch Scripting myself so I know what it's like to not have the greatness of the GoTo command *sniff* *sniff*

But we will have to do.

To create a loop in a batch file you probably would have done something liek this:

CODE
:BEGIN

ECHO Hello World!

GOTO BEGIN

For AutoIt you can do something like this:

While 1 = 1
MsgBox(0, "Hello World!", "Hello World!")
WEnd

Hope that helped

By the way, check out my site for awesome batch file programs I've made :P

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

I'm not quite sure if that's a compliment or insult. So I'll just stare.... :P

Why ... didn't you bring up this idea ? :D

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

Share this post


Link to post
Share on other sites

Alright, thats good to know. So if I was at the end of the script and wanted to call another au3 file based on the entry from a user how would one go about that.

Share this post


Link to post
Share on other sites

Alright, thats good to know...

It seems that you already have your answer, but here is some more info:
While 1 ;this would be like your label
    MsgBox(0, "", "Hi")
WEnd ;this would be like telling AutoIt to goto the labeloÝ÷ Ù«­¢+Ù]¡¥±Ä(5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí$Ìäí´½¥¹Ñ¼¼Í½µÝ¡É¸ÅÕ½Ðì¤(}ͽµÝ¡É ¤íÑ¡¥Ì¥Ì±¥­¹½Ñ¡ÈÑåÁ½½Ñ¼(5Í   ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí$Ìäí´¬¸ÅÕ½Ðì¤)]¹()Õ¹}ͽµÝ¡É ¤(5Í    ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí$Ìäí´Í½µÝ¡É¸ÅÕ½Ðì¤)¹Õ¹ìôôÐí}ͽµÝ¡É

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Simply put, AutoItv3 is a murderer!

Simply put, AutoItv3 is murder!

Take your time - you will get it... maybe.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

GoTo is the same thing as using a function.... there is absolutely no difference besides the command name, and the fact that functions can also have parameters.

Batch:

ECHO Hello World!
GOTO BEGIN

:BEGIN
ECHO begin has been called.

AutoIt:

MsgBox(0, "Title", "Hello World!")
Begin()

Func Begin()
     MsgBox(0, "Title", "Begin has been called.")
EndFunc

The AutoIt code looks a little more intimidating at first, but the extra parameters can proove to be quite useful over time. Just stick with it, and keep learning.

Edited by dandymcgee

- Dan [Website]

Share this post


Link to post
Share on other sites

Thats hot! I love it. I'm scripting up one side of my machine and down the other now. Thanks for every ones help.

Share this post


Link to post
Share on other sites

I was looking for the goto command myself. After a few hours of playing with the Func command I was able to make it work. I can see why learing that was important, but I did finally figure out how to create a goto like command. It was prety simple and I could have shot myself for not figureing it out sooner. I tried to use a null variable but AutoIT did not like that.

Curtiss W.

CODE
; Adding a goto like fuction in AutoIT V3.; All you need to do is add a variable early in you program. I am going to call; mine goto1. (Then any where you really need to use a goto command you can just; uase a If Then statement.$goto1 = "1" ;Setting up the goto variableIf $goto1 = "1" Then label_name() ; Change label name to the name you are using.

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