Page 1 of 1

Save way to check for empty Macro parameters

Posted: Mon Dec 08, 2008 7:30 pm
by technicorn
Right now there is no save way to check if a Macro parameter is empty.
You could use this trick, but the last one will not work, because the compiler
complains about to many characters between ''

Code: Select all

Macro SQCHAR
'
EndMacro

Macro SQTME(x)
SQCHAR#x#SQCHAR
EndMacro

Macro m1(param=)
CompilerIf SQTME(param) <> ''
  Debug param
CompilerElse
  Debug "nothing"
CompilerEndIf
EndMacro

a = 1234
verylongvariable = 1
m1()
m1("Hello")
m1(a)
m1(verylongvariable)
Would be nice to have something like

MacroParameterIsEmpty(param)

Which could return 1 for empty param

Or

MacroParamterLen(param)

Which could return the lenght of the parameter.

Or more general

ExpandedLen(anything)

Which does a normal expansion like already done in macro expansion
and then inserts the constant value for the lenght of the expanded text.

Or use Defined(param) with only one parameter and it gives back 0/1 ?

Of course all those would be compile time functions

Seasons's greetings
Technicorn