OK, so I've made some progress on this idea : I've been able to use sampler to read motion.program−line, but the output to a text file still needs some work : halsampler creates the file but it remains empty. I think I might need to close the file at some point, but I still need to figure out when and how to do it. Also, it seems that motion.program−line is actually the count of line processed from the beginning of the session, not from the start of the ngc file ? I still need to double-check to make sure.
On another note, I've experimented with the use of Start-from-line : it works, but in my case, if the spindle was stopped, it won't restart it. I guess this is normal, but this means that I really need some sort of script, maybe run from a button on the UI, to resume the execution of the G-Code with all required pre-commands, so that I won't forget anything important. So the sampler/halsampler might need to store more than just the line number, so that I can create a script that restores proper conditions before resuming the file processing.
More on this later, but I will be away from the machine for some days