AutoHotkey Community

It is currently May 27th, 2012, 12:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: If(Expression) or?
PostPosted: October 9th, 2009, 4:28 am 
Offline

Joined: November 4th, 2008, 10:25 pm
Posts: 222
Location: Memphis, TN
How many expressions combined with "and or "or" will an If(expression) allow?

This code works and returns true on the If(ex) but how far can I go if I added more variables?
Code:
a := 1
b := 1
c := 1
d := 1

If(a = b or a = c or a = d or b = c or b = d or c = d)
   {
      msgbox something matches another var
   }
Else
   {
      msgbox nope nothing matches
   }
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 9:15 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Ok, I got it:
Code:
a=1
b=2
c=3
d=1
e=2
f=3
comp=
( Ltrim
b
c
d
e
f
g
)

Stringsplit,comp,comp,`n

Loop, %comp0%
{
  testvar:=comp%A_INDEX%
  testvarr:=%testvar%
  MsgBox % "a: " . a . " testvar: " . testvar . " testvarr: " . testvarr
  if (a = testvarr)
   GOSUB same
}

Return

same:
  msgbox % "a and " . testvar . " are the same!"
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 11:35 am 
Offline

Joined: November 4th, 2008, 10:25 pm
Posts: 222
Location: Memphis, TN
Thanks aaffe, but I think you misunderstood my question.

I was wondering how many separate expressions can be used in an if(expression) statement.
I didn't really need to check if one variable matched another (although I appreciate the the time you spent coding! :D) I was just using that bit of code as an example.

So, how many separate expressions will an if(expression) allow?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 11:38 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Sorry, but I dont know that....perhaps someone else.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 3:37 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
If reference to this topic is appropriate then it would be 200. I'm not exactly sure that topic specifically addresses this question but given that you would essentially be concatenating several comparisons together I would think so.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 3:53 pm 
Offline

Joined: November 4th, 2008, 10:25 pm
Posts: 222
Location: Memphis, TN
Thanks sinkfaze.

This post was dated in 07 so I am sure Chris has doubled the number of expressions by now.

So 200. Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 4:41 pm 
godsstigma wrote:
Thanks aaffe, but I think you misunderstood my question.

I was wondering how many separate expressions can be used in an if(expression) statement.
I didn't really need to check if one variable matched another (although I appreciate the the time you spent coding! :D) I was just using that bit of code as an example.

So, how many separate expressions will an if(expression) allow?

I believe you answer can be found here: http://www.autohotkey.com/forum/post-268985.html#268985
Quote:
the limitations I know of are:

Each line of script may be up to 16384 characters. Note that in the following example, there is only one "line":

Code:
If (x = A
or x = B)

Each expression can have no more than 512 tokens. Each operator (open/close parenthesis, 'or', '=', etc.) or operand (variable or function reference, literal string, number, etc.) counts as one token. For instance, in the code above there are 9 tokens.

There can be no more than 512 derefs (variable references or function calls), but the above limit will typically be reached first.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 10:50 pm 
Offline

Joined: November 4th, 2008, 10:25 pm
Posts: 222
Location: Memphis, TN
Thanks alexy.

My only question now is where the hell did Lexicos get that info?
Could it be commented in the AHK source?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 10th, 2009, 3:09 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
It's in defines.h, the AHK source is really well commented, it's just a lot of code.

Code:
// AutoIt2 supports lines up to 16384 characters long, and we want to be able to do so too
// so that really long lines from aut2 scripts, such as a chain of IF commands, can be
// brought in and parsed.  In addition, it also allows continuation sections to be long.
#define LINE_SIZE (16384 + 1)  // +1 for terminator.  Don't increase LINE_SIZE above 65535 without considering ArgStruct::length's type (WORD).
...
#define MAX_TOKENS 512 // Max number of operators/operands.  Seems enough to handle anything realistic, while conserving call-stack space.
...


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: Bing [Bot], BrandonHotkey, Google Feedfetcher, Leef_me, Pulover, rjgatito, XstatyK, Yahoo [Bot] and 14 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