To check whether the variable exists, use RCL within an IFERR structure,
like this:
\<<
'XXX'
IFERR
RCL
THEN
(whatever action to take if the variable doesn't exist goes here)
ELSE
DROP (whatever action to take if the variable does exist goes here)
END
\>>
You may want to refine the THEN clause by nesting a conditional (IF...
or CASE...) structure in there with ERRN to check that the error was
really #204h, "Undefined Name".
But note that this checks whether the variable exists anywhere on the
current path. To restrict the search to the current directory, maybe:
\<<
VARS 'XXX'
IF
POS
THEN
(whatever action to take if the variable does exist goes here)
ELSE
(whatever action to take if the variable doesn't exist goes here)
END
\>>
But note that VARS is slow when the current directory is large.
What you want to do resembles what happens when the calculator receives
a file with the same name as an existing variable in the same directory
and flag -36 is clear, so there may well be a SysRPL entry that would
help you.
Regards,
James