I am working on a macro to quickly set Tool Length offsets .
The program I have here uses 2 options for A. 1 - records tool lengths from a standard, 2 - sets offsets from part. B is the number of tools.

%
O99999
(TOOL LENGTH OFFSET MACRO)
(SET A EQ 1. TO READ ORIGIN)
(SET A EQ 2. TO SET OFFSET)
(SET B EQ TO NUMBER OF TOOLS)

IF [[ROUND[#1] NE 1] AND [ROUND[#1] NE 2]] GOTO 9101;
IF [#2 LE 2] GOTO 9102;
IF [ROUND[#1] EQ 1] GOTO 1;
IF [ROUND[#1] EQ 2] GOTO 2;




N1 #32 = #2;
#103 = [#2001];
#101 = 1;
WHILE [#32 GT 0] DO1;
#[100 + #101] = [ #[2000 + #101]]; <----- gives illegal macro variable
#101 = #101 +1;
#32 = #32 -1;
END1;
GOTO 9999;

N2 #32 = #2;
#103 = #103 - [#2001];
#101 =2;
WHILE [#32 GT 0] DO1;
#[2000 +#101] = [#[100 + #101] + #103];
#101 = #101 + 1;
#32 = #32 -1;
END1;
GOTO 9999;

N9101 #3000 = 101 (EITHER 1 OR 2);
N9102 #3000 = 102 (AT LEAST 2 TOOLS);

N9999 M99;
%

I am getting an illegal macro variable reference at the indicated line starting when #101 = 2;
Please help. When I use the same program but change it to the 2200 range for wear offset I get no error.