I don't know of a function to find out if a variable is defined in Automic script.
There is a rather silly trick though: You can initialize any variable by itself, like so:
:set &dirty_hack# = &dirty_hack#
If &dirty_hack# had a value before, that value will be retained. If &dirty_hack# was not initialized, it will now be initialized and empty, so you can distinguish with:
:if &dirty_hack# = ""
: print "empty"
:else
: print &dirty_hack#
:endif
And more importantly, your script will now not fail with an U00021719: Undefined Variable error. At the expense of making your script a little bit larger, wasting a few bytes and CPU cycles, and being a bit silly.
Kudos once more to
MatthiasSchelp for pointing me to this.