1
Mach4 General Discussion / Re: How to change probe parameters
« on: August 12, 2023, 05:53:24 PM »
The dro code for the OnModifyScript of each of the Probing settings needs to be changed in exactly the same way as you have already done for the PersistentDROs. See the example heare that I use for the FastFeed dro:
Essentially, you should only need to modify line 2, replacing it by the select(1, …) statement, which retrieves the numeric value you typed into the field and saves it in the variable val; and to add the last line, if it is missing, which returns your changes and allows the new value to be stored in the dro. The return statement must always be on the last line. That’s it!
Line3 saves a text representation of the new value in the machine.ini file. You can open this file in a text editor, e.g. Notepad, if you wish and search for the section [ProbingSettings] . Under this heading you will see all of the values that have been saved from the Settings screen. Previously, you were saving values in another section, [PersistentDROs]. All of these values are saved in the machine.ini file so that they can be retrieved and used to populate the on-screen dros next time you start Mach4.
Notice that val is a number and needs to be converted to a text string for use in the function mcProfileWriteString(). This conversion can be done with either the tostring() or string.format() functions, which are similar, so either should work. In short, you shouldn’t need to change line 3. .
Line 4 simply writes a message to the status line at the bottom of the screen: its use is optional and you can alter the message element to suit your preferences should you wish. Again, it is not necessary to change this line.
I hope this helps you to see the similarity between what you are faced with now and what you previously tackled. As I said earlier, the sheer number of functions that need to be updated makes this a tedious procedure, but you may as well do all of them whilst it is fresh in your mind – it doesn’t actually take that long once you get into the swing of it. Best of luck!
Allan
Code: [Select]
local inst = mc.mcGetInstance()
local val = select(1,...) -- Get the user supplied value.
mc.mcProfileWriteString(inst, "ProbingSettings", "FastFeed", string.format(val))
mc.mcCntlSetLastError(inst, "Probe: Fast find feedrate updated")
return val
Essentially, you should only need to modify line 2, replacing it by the select(1, …) statement, which retrieves the numeric value you typed into the field and saves it in the variable val; and to add the last line, if it is missing, which returns your changes and allows the new value to be stored in the dro. The return statement must always be on the last line. That’s it!
Line3 saves a text representation of the new value in the machine.ini file. You can open this file in a text editor, e.g. Notepad, if you wish and search for the section [ProbingSettings] . Under this heading you will see all of the values that have been saved from the Settings screen. Previously, you were saving values in another section, [PersistentDROs]. All of these values are saved in the machine.ini file so that they can be retrieved and used to populate the on-screen dros next time you start Mach4.
Notice that val is a number and needs to be converted to a text string for use in the function mcProfileWriteString(). This conversion can be done with either the tostring() or string.format() functions, which are similar, so either should work. In short, you shouldn’t need to change line 3. .
Line 4 simply writes a message to the status line at the bottom of the screen: its use is optional and you can alter the message element to suit your preferences should you wish. Again, it is not necessary to change this line.
I hope this helps you to see the similarity between what you are faced with now and what you previously tackled. As I said earlier, the sheer number of functions that need to be updated makes this a tedious procedure, but you may as well do all of them whilst it is fresh in your mind – it doesn’t actually take that long once you get into the swing of it. Best of luck!
Allan