grey1beard,
I don't have a clear picture, but will throw out a couple of things to maybe make you think in a new direction.
You asked:
> For example, is there a way to give the position X[5] Y[10] as #1, and X[6] Y[15] as #2?
I wonder.
If X and Y were each bounded, and you had enough vars at your disposal, you store both as a single "code" value by some formal; e.g., X[5]Y[10] is stored as 5.1099999 and X[6]Y[15] as 6.1599999, presuming no negative numbers. Negative numbers might be handled by adding a very large number to each first 999990000000000 to each before converting. How about -5.1109999 to represent X[-5]Y[-10]? The problem of saving X[-5.1]Y[-5.1] is left as an exercise to the math professors who are reading this, while looking for help with the CNC machines they built for relaxation. I wonder if "prime numbers" would help... but I diva...
I also stumbled on this in this:
linuxcnc.org/docs/html/gcode/overview.ht...umbered_parameters_a
which refers to what in programming circles is called pointer arithmetic, and indirect pointers.
"Of course, #[1+2] does mean the value found in parameter 3. The # character may be repeated; for example ##2 means the value of the parameter whose index is the (integer) value of parameter 2."
This suggests that it might be possible to create an "indexed" array of say R rows and C columns, stored as a 1-dimensional array, also common with programmers. A single number "index" i refers to a single element of the array; if the index is less than R, it is in the first row: it's position being given by the column its in. So in that case, the i-th element is in Row0,ColC: one number indicates 2.
If i is larger than R, multiples of C are subracted from i (corresponding to the number of rows that have to be traversed, each of length C) before the remainder is a number less than R, after which you know it's the "i-th element of the array refers to the element in ColC of RowR.
So you'd be treating X and Y positions as R and C into an array, computing an I and storing something in #<I>.
Moving to the last bit, about ##2, it's easy for mere mortals to grasp WHAT it is, but hard to conceive how it's to be used. It's an "indirect parameter" which says, "fetch the contents of param #2, and interpret that as the number of ANOTHER parameter and fetch the contents from there to get the value". Right away you can guess that storing non-positive integers or floats would be bad for a ## use, but consider storing the number 5420 in #2, and reading it out and iterating. ##2 would give you the value of whatever's stored in #5420, which happens to be current X, after iterating #2=[#2+1] , the same expression ##2 would now give you the value of Y.
Anyway I hope this helps--even if only to give you some much-need shuteye.
Cheerio,