AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Comma at same open brace at IfMsgBox

 
Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Sun Sep 20, 2009 7:17 pm    Post subject: Comma at same open brace at IfMsgBox Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sun Sep 20, 2009 11:06 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Mon Sep 21, 2009 10:24 am    Post subject: Reply with quote

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.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Mon Sep 21, 2009 12:54 pm    Post subject: Reply with quote

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
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Mon Sep 21, 2009 10:28 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Tue Sep 22, 2009 2:14 am    Post subject: Reply with quote

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 Cool
Back to top
View user's profile Send private message Send e-mail Visit poster's website
JBensimon



Joined: 16 Nov 2004
Posts: 153
Location: New York

PostPosted: Sat Sep 26, 2009 8:27 pm    Post subject: Reply with quote

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! Smile

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.
Back to top
View user's profile Send private message Visit poster's website
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Mon Sep 28, 2009 9:13 am    Post subject: Reply with quote

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 Smile
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
JBensimon



Joined: 16 Nov 2004
Posts: 153
Location: New York

PostPosted: Mon Sep 28, 2009 12:34 pm    Post subject: Reply with quote

Quote:
not an invitation for a flamewar
No worries, not my style. Smile 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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group