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 

If(Expression) or?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
godsstigma



Joined: 04 Nov 2008
Posts: 189
Location: Memphis, TN

PostPosted: Fri Oct 09, 2009 3:28 am    Post subject: If(Expression) or? Reply with quote

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
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 942
Location: Germany - Deutschland

PostPosted: Fri Oct 09, 2009 8:15 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
godsstigma



Joined: 04 Nov 2008
Posts: 189
Location: Memphis, TN

PostPosted: Fri Oct 09, 2009 10:35 am    Post subject: Reply with quote

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! Very Happy) I was just using that bit of code as an example.

So, how many separate expressions will an if(expression) allow?
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 942
Location: Germany - Deutschland

PostPosted: Fri Oct 09, 2009 10:38 am    Post subject: Reply with quote

Sorry, but I dont know that....perhaps someone else.
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 2431

PostPosted: Fri Oct 09, 2009 2:37 pm    Post subject: Reply with quote

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.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
godsstigma



Joined: 04 Nov 2008
Posts: 189
Location: Memphis, TN

PostPosted: Fri Oct 09, 2009 2:53 pm    Post subject: Reply with quote

Thanks sinkfaze.

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

So 200. Thanks!
Back to top
View user's profile Send private message
alexy
Guest





PostPosted: Fri Oct 09, 2009 3:41 pm    Post subject: Reply with quote

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! Very Happy) 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.
Back to top
godsstigma



Joined: 04 Nov 2008
Posts: 189
Location: Memphis, TN

PostPosted: Fri Oct 09, 2009 9:50 pm    Post subject: Reply with quote

Thanks alexy.

My only question now is where the hell did Lexicos get that info?
Could it be commented in the AHK source?
Back to top
View user's profile Send private message
entropic



Joined: 21 Dec 2008
Posts: 161

PostPosted: Sat Oct 10, 2009 2:09 am    Post subject: Reply with quote

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.
...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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