Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Eval boolean logic?


  • Please log in to reply
4 replies to this topic
highend
  • Members
  • 49 posts
  • Last active:
  • Joined: 02 Jun 2009

Hi,

 

Let's say you read a line from an .ini file

 

IniRead, ini_Conditions, test.ini, General, Conditions

 

The content of ini_Conditions is now:

{var} != 2 AND {var} != 3 AND {var} != 7

 

After replacing all {var} strings with the value belonging to it

like:

8 != 2 AND 8 != 3 AND 8 != 7

 

Is there any way to let AHK evaluate this boolean logic (so that in this case the end result = true)?

 

The comparison operators are treated as normal strings so I cannot just use an if () expression...

 

 

 



floodindahood
  • Members
  • 383 posts
  • Last active: Apr 20 2018 01:45 PM
  • Joined: 21 Oct 2011
There actually is a function for that, its called "eval()" (evaluates a string as an expression) and you should be able to find it from google with 'ahk eval'. Currently on phone so finding the link and stuff is a bit mehhy.

highend
  • Members
  • 49 posts
  • Last active:
  • Joined: 02 Jun 2009

You mean: http://www.autohotke...ns-dynamically/

?

 

Doesn't work for me...

msgbox, % eval("8 != 7")

Is just empty...



gilliduck
  • Members
  • 109 posts
  • Last active: Nov 09 2015 01:07 AM
  • Joined: 19 Dec 2013

You put the eval.ahk file into your Lib folder right? If it still doesn't work, it probably won't due to our versions of AHK being too new. I think the documentation for it says it may not run on higher than 1.1.08. I'm personally on 1.1.22.02 at the moment and it doesn't work either.



highend
  • Members
  • 49 posts
  • Last active:
  • Joined: 02 Jun 2009

 

You put the eval.ahk file into your Lib folder right?

Sure, otherwise AHK would have mentioned that I'm trying to call a non existent function :)

 

On the latest AHK version and it doesn't make sense to go back so far for this function. Although it would be great to have it (on new AHK versions)...