AutoHotkey Community

It is currently May 27th, 2012, 10:49 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: November 12th, 2004, 3:22 am 
Offline

Joined: November 6th, 2004, 11:03 am
Posts: 170
Location: Salt Lake City, UT
Besides sticking a message box command in my script every time I need to operate based on the value of errorlevel, is there some way that I can monitor what it's current value is (and possibly what command is changing it)?

I wondered if using a script like Gre's http://www.autohotkey.com/forum/viewtopic.php?t=1062 would do the trick, but maybe there is a better way.

This is what Gre's script looks like:
Code:
Progress , M CtLime CwBlack FS12 W200 Y-27 ZB0 ZY1, XXXX,,statusmon
Loop
{
     StatusBarGetText, ?status, 1, ahk_class IEFrame
     StringSplit, ?status, ?status, %A_Space% ;is it necessary?
     Progress , ,%?status%
     Sleep, 300
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 3:31 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
is there some way that I can monitor what [ErrorLevel]'s current value is (and possibly what command is changing it)?
As you know, since many commands set ErrorLevel, it's best to check it immediately after any command for which its value is important. Currently, there's not much else you can do.

On a related note, you can open the script's main window and choose the menu item on View > Variables to see the contents of ErrorLevel and other variables. You can press F5 to refresh as needed.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 4:45 am 
Offline

Joined: November 6th, 2004, 11:03 am
Posts: 170
Location: Salt Lake City, UT
:oops: Thanks Chris.

Here's another question that probably has an obvious answer:

How do I write an AND with IF commands? I want to only do something if two different conditions are met. Is it as easy as putting one IF right below the previous one?

Code:
if a_index > 1
If a_thishotkey = !#p


This code doesn't seem to work for me. It's within a non-hotkey gosub that gets called from a loop.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 5:56 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
Sometimes,when debugging a script,I use sounds to tell me the errorlevel value, if errorlevel is "bad"
the script plays a sound followed by other sounds that represents each errorlevel value.
You can also use only beeps.To play a beep:
Code:
RunWait,%comspec%  /c ECHO •,,Hide


Quote:
if a_index > 1
If a_thishotkey = !#p
it would be good to see more portions of the code


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 1:39 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
How do I write an AND with IF commands?
You're on the right track. An "and" would typically be written this way:
Code:
if a_index > 1
    if a_thishotkey = !#p
    {
        ...
    }

Unfortunately, the above can make "else" harder to use since now you have two IFs, each of which would require an else rather than just one.

In case you don't know, some simple "and" and "or" tasks (though not the one you mentioned) can be handled with the following:
if var [not] between 1 and 10
if var [not] in 1,3,5,7
if var [not] contains substring1,substring2

I know AutoHotkey is very limited in this area. Hopefully there will be some improved syntax in a future version.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, Google Feedfetcher, HotkeyStick, Yahoo [Bot] and 35 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