with great thanks to deszoe for helping me extract the tool numbers from the loaded code.
this is my final result.
code runs automatically at the start of a gcode file in my machine pre check conditions macro.
used to pre check machine tool loaded status before running a file.
my machines are often run by operators who make mistakes. this helps catch them so decreases support time
also stores all tool numbers in order ready for my new design "hot swap" tool changer which requires next tool pre loaded before tool change begins.
this code only works on my own machines due to how tools are stored and sorted etc.
https://youtu.be/vMS-gNsKrxc?si=vwse_50cDzhWgMpX