| View previous topic :: View next topic |
| Author |
Message |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Sun Sep 20, 2009 7:17 pm Post subject: Comma at same open brace at IfMsgBox |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Sun Sep 20, 2009 11:06 pm Post subject: |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Mon Sep 21, 2009 10:24 am Post subject: |
|
|
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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Mon Sep 21, 2009 12:54 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Mon Sep 21, 2009 10:28 pm Post subject: |
|
|
| 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 |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Sep 22, 2009 2:14 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
JBensimon
Joined: 16 Nov 2004 Posts: 153 Location: New York
|
Posted: Sat Sep 26, 2009 8:27 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Mon Sep 28, 2009 9:13 am Post subject: |
|
|
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  _________________
(Common Answers) |
|
| Back to top |
|
 |
JBensimon
Joined: 16 Nov 2004 Posts: 153 Location: New York
|
Posted: Mon Sep 28, 2009 12:34 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
|