I've added a new test condition ISNONE which should handle these cases. Code is in the attached patch file.
What it does is add a test for a NONE or "" content of a variable. So, this will work:
if IsNone _LastGroove
print There is no LastGroove
else
Groove $_LastGroove
Note, the argument MUST be a system variable name (_LastGroove) or a user variable name (FOO). No leading $ in either case.
Going back to your original example using $_StackValue you would need to use an intermediate variable:
zz = $_Stackvalue
if IsNone zz ...
I think this matches the syntax of NDEF and DEF.
Before I commit this, do we need a NotNone?
What to do with an arg which isn't a defined name? Right now it errors ... which means one should use a IF DEF before the call.