Added September 2021
Variables whose names begin with "%" will be exempted from the normal variable mapping rules, i.e. will be auto-mapped, in the following cases:
| • | FOR...NEXT loop counter - if the loop counter variable name is of the form %name, it will be auto-mapped as F,6 but it's scope will be limited to the loop. |
| • | Within a function or procedure - any variable of the form %name within a function or procedure will be auto-mapped as F,6 and variables of the form %name$ will be auto-mapped as S,0 (dynamic strings). In either case, like variables explicitly mapped within the routine, they are initialized at the start of the routine and freed at the end of it. For example: |
Function Fn'Foo3(seed as i4:inputonly)
%x = rnd(seed) ! auto map1 %x,f,6
%ran$ = "Random number sequence: " ! auto map1 %ran$,s,0
for %i = 1 to 10 ! auto map1 %i,f,6
%x = rnd(0)
%ran$ += str(%x) + ","
next %i
? %ran$;"..."
EndFunction
Note that the ability to auto-map variables within a function should not be taken as a blanket invitation to stop mapping local variables! The idea is mainly to use them for incidental, intermediate or temporary values with such limited scope that having to having to map them is more of a distraction than an aid to code readability.
See Also
History
2021 September, A-Shell 6.5.1706: Feature added to A-Shell