It deals with Defined[] and arrays.
Before the undeclared variables patch you could do something like this:
Code: Select all
sub main
/declare myArray[20] string local NULL
/echo ${Defined[myArray[1]]}
/return
Code: Select all
sub main
/declare myArray[20] string local NULL
/echo ${Defined[myArray]}
/return
For a more specific example, I have a function that retrieves settings from an INI, automatically declares variables if the arguments passed tell it to, and things like that. So, as part of that, it passes in the variable name to store the INI setting into. When I'm loading arrays it would pass in the variable name as myArray[1] so that it does the /varset, it sets the value to myArray[1].
Example:
Code: Select all
sub main
/declare iniName string outer myini.ini
/declare myArray[20] string outer NULL
/for i 1 to 20
/call iniLoad General Setting${i} myArray[${i}]
/next i
/return
sub iniLoad(iniSection, iniKey, variableName)
/declare iniValue string local
/if (${Defined[${variableName}]}) {
/varset ${variableName} ${Ini[${iniName},${iniSection},${iniKey},NULL]}
}
/return
Anyway, I got around it for now by defining another string and parsing out the array name using ${variableName.Left[${Math.Calc[${variableName.Find[[]} - 1]}]}. I'm just not sure if it's an unintended bug that someone might want to be aware of.
Also, this probably isn't the right place to ask this, but while I'm posting I'm also wondering if it would be possible since all these changes were made, to have an optional default value for function arguments. So that instead of everything defaulting to NULL if it's not defined, you can specify it's default value if it's not passed in.
Example:
Code: Select all
sub myFunction( bool myBoolean TRUE, string myString SOME VALUE )
/return


donations for this month's patches.
