 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Skay Guest
|
Posted: Fri Aug 22, 2008 5:15 pm Post subject: Else with no matching if error, need help |
|
|
Hello,
this is a part of an script that would have to verify the status of an application screen, but Iīm getting the Else with no matching if error, where is the error?
| Code: |
WinActivate My application
Send, {enter}
Sleep, 1000
Loop,
{
MouseClickDrag, L, 44, 96, 957, 415, 0
Send, ^c
ClipWait ; Wait for the clipboard to contain text.
if Clipboard contains change succesful
break
else
{
if Clipboard contains warning
send {F3}
}
else
{
if Clipboard contains locations, location
{
Click 909, 364
Click 907, 388
Send, {enter}
}
}
}
|
What are the mistakes here? because Iīm sure there are more than one
Thanks, |
|
| Back to top |
|
 |
Sivvy
Joined: 21 Jul 2008 Posts: 711 Location: Calgary, AB, Canada
|
Posted: Fri Aug 22, 2008 5:25 pm Post subject: |
|
|
I went through and properly indented your code. Right off the bat, I noticed one problem...
| Code: | WinActivate My application
Send, {enter}
Sleep, 1000
Loop,
{
MouseClickDrag, L, 44, 96, 957, 415, 0
Send, ^c
ClipWait ; Wait for the clipboard to contain text.
if Clipboard contains change succesful
break
else
{
if Clipboard contains warning
send {F3}
}
else
{
if Clipboard contains locations, location
{
Click 909, 364
Click 907, 388
Send, {enter}
}
}
} |
|
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Fri Aug 22, 2008 5:55 pm Post subject: |
|
|
| Code: | WinActivate, My application
Send, {Enter}
Sleep, 1000
Loop
{
MouseClickDrag, L, 44, 96, 957, 415, 0
Send, ^c
ClipWait ; Wait for the clipboard to contain text.
If Clipboard contains change,successful
break
If Clipboard contains warning
Send, {F3}
Else If Clipboard contains locations,location
{
Click 909, 364
Click 907, 388
Send, {enter}
}
} |
I'm guessing the error was because you omitted a comma in the first MatchList, misspelled successful, added a space in the third MatchList, or a combination of the three. _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Skay Guest
|
Posted: Fri Aug 22, 2008 6:43 pm Post subject: |
|
|
| Ok, Iīll try to check everything, but because of the syvvy message, I thought that I have to add an if command, because the two else are in red. Can I write an if followed by to else instances? Syvvy, I think that I didnīt understand your reply. |
|
| Back to top |
|
 |
Skay Guest
|
Posted: Fri Aug 22, 2008 9:52 pm Post subject: |
|
|
| I still donīt understand why sivvy put the two else in red, are they wrong? |
|
| Back to top |
|
 |
poo_noo
Joined: 08 Dec 2006 Posts: 137 Location: Sydney Australia
|
Posted: Sat Aug 23, 2008 10:01 am Post subject: |
|
|
maybe the first ELSE should be an ELSE IF..... or maybe the last ELSE is an orphan. _________________ Paul O |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1496
|
Posted: Sat Aug 23, 2008 10:12 am Post subject: |
|
|
| Code: |
WinActivate My application
Send, {enter}
Sleep, 1000
Loop,
{
MouseClickDrag, L, 44, 96, 957, 415, 0
Send, ^c
ClipWait ; Wait for the clipboard to contain text.
if Clipboard contains change succesful
break
else
{
if Clipboard contains warning
send {F3}
else
{
if Clipboard contains locations, location
{
Click 909, 364
Click 907, 388
Send, {enter}
}
}
}
} |  _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sat Aug 23, 2008 10:15 am Post subject: |
|
|
This is your original code reduced to the minimum and indented
| Code: | if something
dothis
else
{
if something
dothis
}
else
{
if something
{
dothis
}
} |
Apart from the mixing of braces/no-braces: If you have another condition, you use else if directly. Else-only is used for the last "anything else case", when you have no conditions left.
| Code: | if something
dothis
else if something
dothis
else
dothis
|
HTH
________________________________________________________
New here? Please, before you post...
1. Read the tutorial and try the examples. -> 2. Take a look at the command list to get an idea of what you could do. -> 3. Create your script. Consult the documentation and the FAQ if you get stuck. -> 4. Search the forum if you need help or examples, method 1 (forum), method 2 (site), method 3 (Google). -> 5. Post your code on the forum in the "Ask for Help" section if you still run into problems (but read this first). -> 6. There is more AHK on autohotkey.net and the Wiki and there is an AHK IRC chat. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|