To determine if a variable defined / declared

Is there a way to determine if a variable is defined or declared on run time before it is actually executed ?I tried using GET_DATATYPE(variable) to see if variable is declared or not based on the data type that was returned, but its just returning blank response.

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.

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.

@ Carsten Schmitz : You can check directly in automic by typing GET_ and Ctrl + Space to see list. However, even i do not see in documentation. Also, I see that it accepts variable as a parameter. So, I just assume it should return the data type (Signed, Unsigned, String and float) as a result.

Thanks, that's interresting. But I now remember a
similar thing: Automic ships a file that is seemingly used for syntax
checking in the script editor. I think it's called syntax.bin or
something like that. I looked through it a long while ago, and found
functions that were in it, but not fully implemented in the engine.

GET_DATATYPE may be one of those, a placeholder for future implementation, or an abandoned feature.