Is NIL argument later defined still a local?
Posted: Fri Jun 05, 2026 12:58 pm
I have my own DisplayBrush function, and I just ran into a situation, which isnt that critical, but just wanting to keep the code clean.
This is just to illustrate the problem, not the real version.
Idea being here that I have an option to pass down the usual Optional Arguments, that are possible to use in DisplayBrush.
However, since in some cases, I want to catch and alter some of those Optional Arguments, it therefore checks if OpArds is something else than NIL. If it is, then it checks those certain cases and alters the values.
But problem comes that in case OpArgs is NIL, then if I use DisplayBrush(ID, X, Y, OpArs) Hollywood crashes, since it is expecting a table.
Therefore in case OpArgs are not given, I need to make OpArgs an empty table.
But since right now this happens inside a IF-ELSE-ENDIF check, will this stil be local, or am I declaring a gloval variable here?
As in, when I use function MyFunc(X, Y)
X and Y are Local by default.
OpArgs itself is Local as well, but in this case, if OpArgs was never given, it is NIL instead. So when I then inside that IF-ELSE-ENDIF check declare OpArgs = {}, is it now actually global declaration, or still just assigning value to the local OpArgs?
Code: Select all
Function MyDisplayBrush(ID, X, Y, OpArgs)
if OpArgs <> NIL
do stuff
else
OpArgs = {}
Endif
DisplayBrush(ID, X, Y, OpArgs)
Main
MyDisplayBrush(1, 200, 300)This is just to illustrate the problem, not the real version.
Idea being here that I have an option to pass down the usual Optional Arguments, that are possible to use in DisplayBrush.
However, since in some cases, I want to catch and alter some of those Optional Arguments, it therefore checks if OpArds is something else than NIL. If it is, then it checks those certain cases and alters the values.
But problem comes that in case OpArgs is NIL, then if I use DisplayBrush(ID, X, Y, OpArs) Hollywood crashes, since it is expecting a table.
Therefore in case OpArgs are not given, I need to make OpArgs an empty table.
But since right now this happens inside a IF-ELSE-ENDIF check, will this stil be local, or am I declaring a gloval variable here?
As in, when I use function MyFunc(X, Y)
X and Y are Local by default.
OpArgs itself is Local as well, but in this case, if OpArgs was never given, it is NIL instead. So when I then inside that IF-ELSE-ENDIF check declare OpArgs = {}, is it now actually global declaration, or still just assigning value to the local OpArgs?