AutoHotkey Community

It is currently May 26th, 2012, 5:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: March 1st, 2009, 12:58 am 
Offline

Joined: July 26th, 2006, 11:25 am
Posts: 19
Great release! Thanks.

I have one wish for a long time now. I also program in C++.
I would like to be able to write stuff like:
Code:
Variable=Test
if(Variable=="Test") msgbox,Test
else msgbox,!Test


But I have to write:
Code:
Variable=Test
if(Variable=="Test")
 msgbox,Test
else msgbox,!Test


Wouldn't this be easy to change? You just have to count Braces and look for strings. Or am I wrong?

_________________
http://www.familie-plentz.de


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 1:20 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
If you're just looking to save lines, it's even shorter with a ternary.
Code:
Variable=Test
MsgBox,% (Variable=="Test") ? "Test":"!Test"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 2:32 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It also seems difficult to support such a syntax due to its ambiguity with implicit (dotless) concatenation.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 8:52 am 
Offline

Joined: July 26th, 2006, 11:25 am
Posts: 19
@Chris
Mh I don't get the point. What implicit (dotless) concatenation do you mean? Can you give an example?

@jaco0646
Thanks, I know this example could be made shorter. It was just an example. I also like the easy readability of ifs.

_________________
http://www.familie-plentz.de


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 11:28 am 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
SamuelPlentz wrote:
@Chris
Mh I don't get the point. What implicit (dotless) concatenation do you mean? Can you give an example?


He's referring to:

Code:
a := "Hello "
b := a "World"
MsgBox % b "!"

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 2:30 pm 
Offline

Joined: July 26th, 2006, 11:25 am
Posts: 19
Ok but why would this lead to ambiguity?
Can you give also an example for this?

_________________
http://www.familie-plentz.de


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 3:56 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
"if (expression) something" is ambiguous because depending on how you look at it, "something" could either be concatenated onto "expression" or be the IF's action. There is more explanation of dotless concatenation at www.autohotkey.com/docs/Variables.htm#concat


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 10:39 pm 
Offline

Joined: July 26th, 2006, 11:25 am
Posts: 19
Now I understand the problem.

Would be nice if you could add braces to the exceptions of implicit (dotless) concatenation. As you have some exceptions for them right now. (+, ++, -, etc)

Please :)

_________________
http://www.familie-plentz.de


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2009, 5:26 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It is already documented than an open-brace may appear to the right of if (expression). The if-expression page says: Unlike an "else" statement -- which supports any type of statement immediately to its right -- an if-[expression]-statement supports only a "{" to its right.

In addition, braces are illegal in expressions; so the program should display an error dialog upon launch if you try to use braces in anything other than if-expression.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2009, 1:58 pm 
Offline

Joined: June 17th, 2008, 7:51 am
Posts: 243
Thanks, thanks, thanks to chris and lexikos. It's fantastic.
Chris wrote:
Krogdor wrote:
The only other thing from Lexikos' that I wish was in this one is the #If hotkey modifier, but it's still very nice to see an official update :D
Hopefully that and some of the other features will be added in the next major release, or maybe a sooner, minor one.
...and this would be even more fantastic. The earlier thew better. The #If-modifier is one of the most helpful things for me. And I like the idea, that you both work on the same AHK. :D

_________________
Greetings
Rog


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2009, 9:02 am 
Offline

Joined: January 27th, 2005, 3:28 pm
Posts: 120
Location: Germany, Dresden
SamuelPlentz wrote:
I have one wish for a long time now. I also program in C++.
I would like to be able to write stuff like:
Code:
Variable=Test
if(Variable=="Test") msgbox,Test
else msgbox,!Test
Wouldn't this be easy to change? You just have to count Braces and look for strings. Or am I wrong?

Concerning this, please Chris, never change AHK in a way so that
Code:
var=Test1
IFEQUAL,     var,test1,SETENV, temp, % my_func1(my_parms)
ELSE IFEQUAL,var,test2,SETENV, temp, % my_func2(my_parms)
ELSE                   MSGBOX, !Test
wouldn't work.
I like this "one line comparisons", they are the only way to easly and readable add conditional commands in a multi condition situation.
The SETENV is also important due to the possibility to add function calls on the same line.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 15th, 2009, 6:47 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Here are the changes for v1.0.48.01:

Changed: For Windows Vista and later, hotkeys that include the Windows key (e.g. #a) will wait for LWin and RWin to be released before sending any text containing an "L" keystroke. This prevents such a hotkey from locking the PC. This behavior applies to all sending modes except SendPlay (which doesn't need it) and blind mode.

Fixed A_LoopFileExt to be blank for any filename having no extension but a period in its pathname. [thanks Yek-Toho-Tua].

Fixed the assignment of integers that are 19 or 20 characters long to work as they did prior to v1.0.48. [thanks Laszlo & Lexikos]

Fixed function definitions to work properly inside a block. [thanks rmarko]

Improved performance of A_Index in expressions by treating it as an integer rather than a string.

Improved performance of "if var [not] in/contains". [developed by Lexikos]

Improved ListLines with an option to turn line-logging Off or On. [thanks kenomby & ruespe]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2009, 10:45 am 
Chris wrote:
Here are the changes for v1.0.48.01:
Improved ListLines with an option to turn line-logging Off or On.

Hi, Chris
Thanks for adding ListLines On/Off Now, how about a "A_ListLines" variable?

I have started using ListLines On/Off in functions where I either want to see or not see the function lines. The obvious problem is that when exiting a function that uses this, there is no current way to know what the ListLines On/Off state was when entering the function.


Top
  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2009, 2:15 pm 
A question. If i turn listlines off, is there any performance gain?


Top
  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2009, 3:05 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Chris wrote:
Although the benchmarks of this version seem to be a few percent worse than the previous version, putting "ListLines Off" near the top of the script makes the benchmarks a few percent faster than the previous version. So maybe it balances out.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot 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