joel_wiesmann_automic

Undeclared variable runtime issue workaround - clever or bug?

Discussion created by joel_wiesmann_automic on Jan 8, 2015
Latest reply on Jan 12, 2015 by joel_wiesmann_automic
Hi there

I guess everybody knows the issue with runtime errors due to access to undeclared variables. However, there is a workaround that at least works for AE10 and I'm not aware whether it is known to the public. The Automic trainer didn't knew about it and guessed it might be a bug so I'd wanted to get the feedback of the community. Possibly someone is using it since ages and has no issues with..

:PRINT &UNDECLARED#
Causes an issue.

:SET &OVERWRITTEN_DECLARED# = 'value'
:PRINT &OVERWRITTEN_DECLARED#
Causes no issue, but overwrites already set values.

:SET &DECLARED# = &DECLARED#
:PRINT &DECLARED#
Causes _no_ issues and does _not_ overwrite the variable content if there was any. If the variable was not declared before, it now is.

So in my opinion it would be clever to do &DECLARED# kind of declaration in scripts that expect variables set by it's caller / runtime context. That way it's possible to do error handling or use default values in cases that variables have not been declared.

Bug or feature?

Regards
Joel

Outcomes