AutoHotkey Community

It is currently May 27th, 2012, 12:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: December 8th, 2005, 12:27 am 
Offline

Joined: September 12th, 2005, 10:35 pm
Posts: 216
:?
1) I found the following exmple:

Code:
WinWait, MyWindow, , 1
if ErrorLevel   ; i.e. it's not blank or zero.
MsgBox, The window does not exist.
else
MsgBox, The window exists.


Why errorllevel is set as blank,and then it is denoting that "it's not blank or zero!!!" ???
------------------------------------

2)Here

it is written that
Quote:
" RunWait sets ErrorLevel to be the exit code of the program it ran. Most programs yield an exit code of zero if they completed successfully."


How to know the exitcode?

-------------------------------------------

3)
The command for runwait is:

Code:
Run, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID]




For UseErrorLevel, used in that command, it is written that:
Quote:
If omitted, Target will be launched normally. Alternatively, it can contain one or more of these words:

Max: launch maximized

Min: launch minimized

Hide: launch hidden (cannot be used in combination with either of the above)



UseErrorLevel: UseErrorLevel can be specified alone or in addition to one of the above words (by separating it from the other word with a space). When the launch fails, this option skips the warning dialog, sets ErrorLevel to the word ERROR, and allows the current thread to continue. If the launch succeeds, RunWait sets ErrorLevel to the program's exit code, and Run sets it to 0.


What does it mean by "sets ErrorLevel to the word ERROR" ?

Can ERRORLEVEL be given values containing letters also?

---------------------------------------

4) Excepting 0, 1, Can errorlevel be given other values in digit?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 6:55 am 
Offline

Joined: August 15th, 2005, 7:15 am
Posts: 107
Location: North Carolina
Hi, I will try to help. I'm not very good at quoting in this type of forum, so I will take your questions as you numbered them.

1. This code DOES work for me. IOW, it gave me the message box saying 'The Window Exists". The only thing I changed was the window title in the first line of your code. If you are waiting for a specific window, you must as with any title-matching, specify either the exact window title, or SetMatchMode to indicate that your title text is a subset of the complete window title, etc. Also, case must match. So since you didn't SetMatchMode, I changed 'MyWindow' to 'AutoHotkey Help' which is a window open on my computer right now.

2. How to know an exit code returned - In early stages of development, you may put in statements you know you won't use later, just to be sure of what is going on. So I would simply do something like this:
MsgBox, Errorlevel is %errorlevel%

At such point you know what exit codes you are looking for, you will change this to check for equalities or inequalities, still using errorlevel. Keep in mind though that you need to check errorlevel immediately, or else store it to another var immediately, as many statements change the errorlevel value, so you need to grab it.

3. 'Errorlevel' is nothing more than a regular var name. We use it for a specific purpose however, and AHK often uses it to pass info back to us. It can contain any data which any variable can contain. You may, in fact, want to use it (set it) yourself in a function to pass info back to the calling code for the function.

4. See above, I think that (hopefully) explains the answer to this.

Best,

Bob

_________________
When it comes to Binary, there are 10 types of people. Those who get it and those who don't. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 8:29 am 
Offline

Joined: September 12th, 2005, 10:35 pm
Posts: 216
Thanks a lot for clarifying question 2,3 and 4.

For Question number 1, The script is working fine for me.

What i asked is that why the blank space is there after errorlevel, and then it is denoting 'It's not blank or zero' .


Code:
WinWait, MyWindow, , 1
if ErrorLevel   ; i.e. it's not blank or zero.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 9:18 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
It is only a comment "It's not blank or zero"
You could also write
Code:
WinWait, MyWindow, , 1
if ErrorLevel
  MsgBox, 1) The window does not exist.
else
  MsgBox, 2) The window exists
The first msgbox will be shown if ErrorLevel is "someting", e.g. meaning it is not blank or zero.
In the case that ErrorLevel is blank or zero the second msgbox will be shown.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 6:55 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
I prefer to write this as:

If Errorlevel = ; if errorlevel is blank or empty

To empty a variable:

var =

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 7:55 pm 
Offline

Joined: December 1st, 2005, 7:04 pm
Posts: 37
Location: Los Angeles, CA
What it means is this -

If the window is found, then the error level will be set to 0 (meaning there was no problem finding it)

then - if errorlevel (meaning if the errorlevel has a value other than 0) proceed to inform the user that there was a problem

but if there was no problem (ie the else command) then inform the user that the window exists.

does that help?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Yahoo [Bot] and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group