AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Macros that return true or false?
 
 

How do you create a macro that does not output any text, it just returns true or false, for use inside an if-else block?

Here is what I want to do:

if (^fact_lt(tim hammer 20))
{
 Output text 1
}
else
{
 Output text 2
outputmacro: ^fact_lt(^subject_name ^verb_name ^amount)

 
@= ^query(direct_sv ^subject_name)
 if (@
0)
 
{
  
if (first(@0object) < ^amount)
  
{
   
return true
  }
  
else
  
{
   
return false
  }
 }
 
else
 
{
  
return false
 }

 

 

 

 

 
  [ # 1 ]

I just found the fail function and that does the job.

^fail(RULE)

 

 
  [ # 2 ]

yes, the documentation says that a function that does not FAIL succeeds. So your macro can be just

if (!test) {fail(RULE)}  or other equivalents.

In 3.0 you can also return 0 or null or nil from a function (by putting it into output) so you could do this if you cared:

if (test) { 1} else {0}

 

 
  [ # 3 ]

Interesting. Can’t wait to see vers 3.0.

 

 
  login or register to react