Author Topic: Expression Nesting...  (Read 1125 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Expression Nesting...
« on: February 20, 2020, 02:42:57 AM »
Im having trouble with this:

Code: [Select]
Result = (IIF(Eval(RIGHT(Conc, 1)="S"), 10, 20))
Code: [Select]
ERROR: ERROR: expression nesting
WORD: )
IN: evaluator
LINE: 1087
FILE: "main source

And this:

Code: [Select]
Result = (IIF(RIGHT(Conc, 1)="S", 10, 20))
Code: [Select]
ERROR: Linker found unidentified names:
1087 mid "main source"
1100 mid "main source

Brian Alvarez

  • Guest
Re: Expression Nesting...
« Reply #1 on: February 20, 2020, 02:46:37 AM »
If i add my own right function:

Code: [Select]
ERROR: Linker found unidentified names:
1090 right "main source"
1103 right "main source

Charles Pegge

  • Guest
Re: Expression Nesting...
« Reply #2 on: February 20, 2020, 08:01:11 AM »
Hi Brian,

Yes I see the problem of functions inside boolean-compare expressions.

Here is an alternative way:

Code: [Select]
macro iif int(R,X,A,B)
  if X
    R=A
  else
    R=B
  endif
end macro

string s="qq"
int result

result = iif (ucase(s) = "QQ", 10, 20)
print result '10

Brian Alvarez

  • Guest
Re: Expression Nesting...
« Reply #3 on: February 20, 2020, 01:54:35 PM »
The problem is that sometimes even the iif could be used inline. like this:


Code: [Select]
result = iif (ucase(s) = "QQ", 10, 20) + xyz
edit:
nevermind, it works. The more you know. How does thes macro works?
« Last Edit: February 20, 2020, 02:05:09 PM by Brian Alvarez »

Charles Pegge

  • Guest
Re: Expression Nesting...
« Reply #4 on: February 20, 2020, 02:51:18 PM »
The macro function is processed first, storing the result in temp variable R. The macro call expression is then replaced by R.

This is how macro functions can be used inline within any expression.