Your wish can be answered in two options :
1. to define min and max as global, then they are changed by the sub and you can refer to their value outside of the sub (and they should not be in the arguments list).
2. to return one variable which is a string : min & "," & max, and then use an array of 2 to split it
Code:
Dim mix(2)
sub min_max(a,b) ... ... returnmin & "," & max end sub
mix() = strsplit(min_max(a,b) , ",") min = mix(0) max = mix(1)
__________________
David Erez
Ramat Hasharon, Israel
Your wish can be answered in two options :
1. to define min and max as global, then they are changed by the sub and you can refer to their value outside of the sub (and they should not be in the arguments list).
2. to return one variable which is a string : min & "," & max, and then use an array of 2 to split it
Code:
Dim mix(2)
sub min_max(a,b) ... ... returnmin & "," & max end sub
mix() = strsplit(min_max(a,b) , ",") min = mix(0) max = mix(1)
Nice workaround, but you still have to have arrays global declared. Erel, is it planned to have posibility declare arrays localy?
Nice workaround, but you still have to have arrays global declared. Erel, is it planned to have posibility declare arrays locally?
How would that work, except by having arrays (or other variables) passed by reference so that the names are local to the Sub but the data that is manipulated is external to the Sub? (Which is what we are promised for a future version.)
Using globals is so clunky because to operate on varied data each has to be loaded into the global(s) before calling the Sub and then "unloaded" afterwards. This doesn't help with the readability of the code.
How would that work, except by having arrays (or other variables) passed by reference so that the names are local to the Sub but the data that is manipulated is external to the Sub? (Which is what we are promised for a future version.)
Using globals is so clunky because to operate on varied data each has to be loaded into the global(s) before calling the Sub and then "unloaded" afterwards. This doesn't help with the readability of the code.
Mike.
You are right, but there is another problem when I want to use in Sub some helping temporary array which won't be used after return. I still have to now define this array Global
... when I want to use in Sub some helping temporary array which won't be used after return. I still have to now define this array Global
Yes, the relaxed implicit-variant treatment of local variables does not work for arrays. This is because all elements of the array have to have the same variant for the indexing mechanism to work (I suppose), so the easy way out is to require all arrays to be declared in a "Dim" before they are used.
Erel has mentioned making variables more sophisticated in the past, so perhaps including a local "Dim" could be introduced for local arrays.