Oxygen Basic
Programming => Problems & Solutions => Topic started by: Brian Alvarez on February 20, 2020, 02:42:57 AM
-
Im having trouble with this:
Result = (IIF(Eval(RIGHT(Conc, 1)="S"), 10, 20))
ERROR: ERROR: expression nesting
WORD: )
IN: evaluator
LINE: 1087
FILE: "main source
And this:
Result = (IIF(RIGHT(Conc, 1)="S", 10, 20))
ERROR: Linker found unidentified names:
1087 mid "main source"
1100 mid "main source
-
If i add my own right function:
ERROR: Linker found unidentified names:
1090 right "main source"
1103 right "main source
-
Hi Brian,
Yes I see the problem of functions inside boolean-compare expressions.
Here is an alternative way:
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
-
The problem is that sometimes even the iif could be used inline. like this:
result = iif (ucase(s) = "QQ", 10, 20) + xyz
edit:
nevermind, it works. The more you know. How does thes macro works?
-
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.