AutoHotkey Community

It is currently May 26th, 2012, 9:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: September 20th, 2009, 8:17 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
From this thread: http://www.autohotkey.com/forum/viewtopic.php?t=49044

I think this is an bug. Not sure if this is documented, but this should be changed. It is unlogical and not strict that a comma after the word "Yes" is required:

Code:
MsgBox 4,Test,Press Yes
IfMsgBox Yes,{
   MsgBox Yes
}

works, but ...
Code:
MsgBox 4,Test,Press Yes
IfMsgBox Yes {
   MsgBox Yes
}

does not work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 12:06 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Technically it's not a bug because it's documented that, "The One True Brace (OTB) style may optionally be used with if-statements that are expressions (but not traditional if-statements)." Also, it's documented somewhere that only the first comma of a command is optional.

Although it probably wouldn't be that complicated to support OTB for IfMsgBox, neither would it be trivial. Another drawback is that it would make IfMsgBox inconsistent with the lack of OTB support in other commands like IfExist, IfInString, and IfWinExist.

So I'm inclined not to change this. Other opinions are welcome.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 11:24 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
My inclination is to ask for IfMsgBox to become deprecated. It's one of the few 'Old style' ifs that does not have a direct replacement (that I know of) with an expression-if.

Ideally, I'd like to see a msgbox's result in A_MsgBox or something like that, which would allow for OTB as well as deprecating IfMsgBox.
Code:

MsgBox 4,Test,Press Yes
If (A_MsgBox = "Yes") {
  Msgbox. Yes
}


On a side note, I'd like to see a note in the docs that certain commands are deprecated and a link to http://en.wikipedia.org/wiki/Deprecation or similar, and a suggestion to use the newer syntax.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 1:54 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
well perhaps something like this is more appropriate turn msg box to a function



Code:
If (MsgBox( 4,Test,Press Yes) = "Yes") {
  Msgbox. Yes
}


however i do like yours as well

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 11:28 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks for the A_MsgBox idea. I don't know how high a priority it should be, but it should be kept in mind for the future.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2009, 3:14 am 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
Hey, I like the idea of having A_MsgBox very much. That would be really ideal, in the sense of current Ahk (Command type). This was originally a (to me bug) report of something that did not work and now we have a new suggestion. cool 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 9:27 pm 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
Quote:
My inclination is to ask for IfMsgBox to become deprecated
I don't mind features being officially and indefinitely deprecated, as long as they're not actually eliminated. As powerful and useful as expression syntax has become in various aspects of AutoHotkey, the old-school "IfCondition" commands still retain their usefulness in terms of clarity and compactness, along with other non-expression commands such as SetEnv. Call me a dinosaur, but I occasionally use one-liners like
Code:
IfMsgBox, YES, IfExist, %Temp%\Data.txt, SetEnv, DelTmpOnExit, Y
... and I also like Coke Classic! :-)

I am however all for also having an A_MsgBox variable to refer to, as long as the rules for its persistence and for the manner in which it might be affected by a MsgBox in another thread are made clear.

Jacques.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2009, 10:13 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
that is the definition of deprecated. It makes sure olde scripts don't break, but it is discouraged for new scripts.

Other threads shouldn't affect A_MsgBox much (A_MsgBoxResult?), since there are other built-in variables that keep the results per thread. Some interesting constructs could be made if the value were allowed to 'hop' threads, though. Those same constructs can also be easily managed with a global var too.

IMHO one-liners like that are harder to read than the 3-line equivalent. That's a personal syntax style opinion, though, and not an invitation for a flamewar :)

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2009, 1:34 pm 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
Quote:
not an invitation for a flamewar
No worries, not my style. :) Plus I'm a big believer in personal choice and recognize that different programmers have different perceptions of what constitutes readable syntax. I just happen to favor compactness (see the APL discussion at http://www.autohotkey.com/forum/viewtopic.php?t=13995&start=24).

Jacques.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 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