Oxygen Basic
Information => Reference => Topic started by: Brian Alvarez on February 08, 2021, 01:48:15 PM
-
Hello, I would like a macro to generate a certain block of code only if one of the passed parameters is not a literal null. What can i use to achieve this safely?
Right now i am using:
#if typecodeof(p) <> 0
#endif
Is this safe? is there a better way? Is it possible?
-
Hi Brian,
Typecodeof will work for null, literals and variables but not for parameters consisting of expressions and functions.
-
I see. Does Typecodeof(null) return 0?
-
Yes, but this might be a better option. I am tweaking the match metafunction to support expressions as well as single words:
macro mf(p)
#if not match((p),(null))
print "not null"
#else
print "null"
#endif
end macro
mf null
mf 0
mf 1/4
-
Thanks Charles, i will implement it. :)