Yes, you can pass the variables to the M-code via the example in the manual (page 62/87 in the current development version manual, section 4.1.2 M-codes)
(I've done it a couple of times I'm just not at my home PC for an example I'll try to load one tonight)
That G96 attempt did it:
viewtopic.php?f=20&t=822