| View previous topic :: View next topic |
| Author |
Message |
godsstigma
Joined: 04 Nov 2008 Posts: 189 Location: Memphis, TN
|
Posted: Fri Oct 09, 2009 3:28 am Post subject: If(Expression) or? |
|
|
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 |
|
 |
aaffe
Joined: 17 May 2007 Posts: 942 Location: Germany - Deutschland
|
Posted: Fri Oct 09, 2009 8:15 am Post subject: |
|
|
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 |
|
 |
godsstigma
Joined: 04 Nov 2008 Posts: 189 Location: Memphis, TN
|
Posted: Fri Oct 09, 2009 10:35 am Post subject: |
|
|
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! ) I was just using that bit of code as an example.
So, how many separate expressions will an if(expression) allow? |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 942 Location: Germany - Deutschland
|
Posted: Fri Oct 09, 2009 10:38 am Post subject: |
|
|
| Sorry, but I dont know that....perhaps someone else. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 2431
|
Posted: Fri Oct 09, 2009 2:37 pm Post subject: |
|
|
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 |
|
 |
godsstigma
Joined: 04 Nov 2008 Posts: 189 Location: Memphis, TN
|
Posted: Fri Oct 09, 2009 2:53 pm Post subject: |
|
|
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 |
|
 |
alexy Guest
|
Posted: Fri Oct 09, 2009 3:41 pm Post subject: |
|
|
| 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! ) 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
|
Posted: Fri Oct 09, 2009 9:50 pm Post subject: |
|
|
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 |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 161
|
Posted: Sat Oct 10, 2009 2:09 am Post subject: |
|
|
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 |
|
 |
|