; set up your times tables
for %x 1 12
{
for %y 1 12
{
set %times %x * %y
gosub AddToArray times_table %times %x %y
}
}
gosub GetFromArray times_table 11 12
display ok 11 times 12 is , #SPC #RESULT
gosub GetFromArray times_table 5 7
display ok 5 times 7 is , #SPC #RESULT
gosub GetFromArray times_table 8 9
display ok 8 times 9 is , #SPC #RESULT
stop
; %1 = Arrayname
; %2 = Value to add
; %3 = index 1
; %4 = index 2
; ...
sub AddToArray
namespace push
namespace local Array , _ , %1
set !var
for !index 3 %0
set !var % . !index , _ , !var
set ! . !var %2
namespace pop
return
; %1 = Arrayname
; %2 = index 1
; %3 = index 2
; ...
sub GetFromArray
namespace push
namespace local Array , _ , %1
set !var
for !index 2 %0
set !var % . !index , _ , !var
set #RESULT ! . !var
namespace pop
return #RESULT