Using O-Codes needs a special command at the beginning of the Gcode.
This command is 'g#2g'. This activates the great library g#2g, which is a subset of LinuxCNC.
For details please see:
https://github.com/nrsoft/gsharp
For example this should works:
g#2g ; Important to activate the lib !!!
#1 = 20
#2 = 2
g91 g1 f500
o100 repeat [3]
x#1
y#2
x-#1
y#2
o100 endrepeat
I have to admit that the special command 'g#2g' came into the program later, and it's nowhere described.
Sorry for that.
Let me point you to the possibility to use the GrblGru macros (toolbar on the right side) for quick checking the O-Code syntax.
For using the macro and the O-codes see link below.
https://youtu.be/5UIVro7R7AU