AutoHotkey Community

It is currently May 27th, 2012, 4:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Line Continuation
PostPosted: September 26th, 2005, 4:25 am 
Offline

Joined: December 15th, 2004, 10:24 pm
Posts: 303
Location: United States
The following is reproducible on Win2000:

Code:
if (Color1 = blankVar and Color2 = "white"
   || Color3 = someOtherColor )
   AND ( ProductIsAvailableInColor = "testVar" )

; AND/OR starting the above line causes error on Win2000
; ||, &&, ",", and "." are accepted

   msgbox, 1
else
   msgbox, 2

Line Text: AND ( ProductIsAvailableInColor = "testVar" )
Error: This line does not contain a recognized action.

The script was not reloaded; the old version will remain in effect.

_________________
1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2005, 6:30 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I know "If expression and expression" works, but I could not find in the Help that it was allowed. Is it?

In your case the extra pair of brackets, like in
Code:
if ( (a = 0)
   AND (c = 0) )
does not make the script work (looks like a bug), but below it makes a difference. This one fails
Code:
if (a = 0)
   AND (b = 0)
 MsgBox True
but this script works
Code:
if (a = 0
   AND b = 0)
 MsgBox True


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2005, 7:52 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
Laszlo wrote:
I know "If expression and expression" works, but I could not find in the Help that it was allowed. Is it?


It is allowed. From the "Expressions" section:

help file wrote:
Although this is usually accomplished by enclosing the entire expression in parentheses, it can also be done with something like if (x > 0) and (y > 0).


and from the "line continuation" section:

help file wrote:
if (Color = "Red" or Color = "Green" or Color = "Blue"
or Color = "Black" or Color = "Gray" or Color = "White")
and ProductIsAvailableInColor(Product, Color)


Unfortunately, this means that there is indeed a bug, handling expressions in conjunction with line continuation.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2005, 8:18 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I overlooked that! Chris, it would be nice to add the same note as at the Expressions to the "If (expression)" Help entry, explaining that "If function(..." and "If (expression)..." don't need the outermost parentheses.

Also, this script is easy to be misunderstood
Code:
if a = 0 or b = 0
   MsgBox True
It is not the same as
Code:
if (a = 0 or b = 0)
   MsgBox True
The first variant tests whether the variable "a" is equal to the string "0 or b = 0", excluding the quotation marks. It shows the danger to be liberal with the syntax.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2005, 10:11 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
Laszlo wrote:
Also, this script is easy to be misunderstood
Code:
if a = 0 or b = 0
   MsgBox True
It is not the same as
Code:
if (a = 0 or b = 0)
   MsgBox True
The first variant tests whether the variable "a" is equal to the string "0 or b = 0", excluding the quotation marks. It shows the danger to be liberal with the syntax.


Exactly! There were many mistrials before I used the various syntax successfully. In the end, I decided to enclose everything within parenthesis.

Oh well... Such is the price to be paid to ensure backwards compatibility.

Now to fix the bug.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2005, 2:37 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Laszlo wrote:
it would be nice to add the same note as at the Expressions to the "If (expression)" Help entry, explaining that "If function(..." and "If (expression)..." don't need the outermost parentheses.
Thanks, I've done this.

Edit: The line continuation issue has been fixed in today's v1.0.38.06.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 2 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:
cron
Powered by phpBB® Forum Software © phpBB Group