I have a simple function with two variables as
/func {
/var1 exch def
/var2 exch def
... process ...
} def
(var2)(var1)func
I want to make var2 optional. However, if not providing var2, it results in stackunderflow error. How can I make a if statement to catch var2 only if the stack is not empty, and probably assign a default value if the stack is empty.
Something like
(Stack is no empty) {/var2 exch def}{/var2 (default) def} ifelse