Cartierusm,
There is already an M6 Macro started in your Mach4 Profile. Once Mach4 is opened, go to "Operator" then "Edit/Debug scripts" it should open up to the Profile Macros. In here will be the M6 that has already been provided. I would suggest copying the original to keep a solid reference point.
Functions, write single register and read register. I use these Registers to tell the PLC what tool to change to, I'm using a side mount tool changer that has an arm to remove the tool from the spindle and put the requested tool in the spindle all in one move. I can give the Click and actual integer from mach4 to do this. Registers in Mach4 can be very useful. They were a bit tricky at first to understand how to get the information from a register and how to write to the register (change it in Mach4)
The Mach4 forum has several examples of how to use them.
But in the Click PLC, you have different types of data bits. You are using "C" bits these are on or off, 1 or 0. There also data bits that can hold real values, integers. These are labeled DS in the Click PLC. In Mach4 you can have Modbus Registers that can be read by the Click and visa versa, Click registers that can be read by Mach.
In your case, You could setup a Write Single Register Modbus Function to tell the Click which tool to change to. In the ladder, you would use the "Compare" Function.
DS1 = 1 -----> Set C1
DS1 = 2 -----> Set C2
ETC.
You would use just one DS#.
I truly am no expert at PLCs or Mach4. I just played around until I figured out what was working well. This is my first go at a PLC. There are several ways to do this. This just worked well for us.
In the morning I will try and remember to take some screenshots of where the registers are in Mach4.
Last thing for the night; to setup a Modbus connection. Go to Configure. Plugins. Modbus. Here you will create a Modbus connection. Click the first Icon, here you will name your Modbus connection, I named mine Click because I'm talking to a Click. You will setup what type of Connection it is. I'm using the Ethernet click so I just had to put in the IP Address of the Click in the second setup screen.
Hope this helps.