I'm trying to send an optional number of parameters to a procedure, and have unspecified parameters take on a default value in the procedure.
Apparently, you can pass as many (or few) parameters to a procedure that you want. Even more than the procedure has defined! However, if you choose not to pass a parameter, it's value in the procedure is set to a seemingly random reference in memory (I think) - definitely not NULL.
(procedure public (TestProc varA varB)
Print("test procedure")
)
...
TestProc()
TestProc(1)
TestProc(2 "test")
TestProc("troll" 29 32 "axe" 892)
All above calls to the procedure work just fine. Just don't reference parameters that weren't specified (you can, but who knows what you'll get). I did find a keyword called 'paramTotal' which can be referenced within a procedure that indicates how many parameters were passed in, which helps:
(procedure public (TestProc varA varB)
(if (== paramTotal 0)
Print("You passed in 0 parameters!")
)
(if (== paramTotal 1)
Print("You passed in 1 parameters!")
)
(if (== paramTotal 2)
Print("You passed in 2 parameters!")
)
)
I'm sure I could put something together for this using the 'paramTotal' variable; I just want to make sure that I haven't missing something in the documentation.