Hi Kenneth,
it's hard to give you the correct code, since I don't know what function codes you have assigned to your controls. Please insert the following code into your code
Open "C:\Mach3\OldState" For output As #1
Write #1, "Inch"
Open "C:\Mach3\OldState" For output As #1
Write #1, "Metric"
Close #1
as shown in the sample.
If Get userLED(1010) = 1 Then
Set UserLabel(1, "Inch")
Set UserLED(1012 , 1)
Set UserLED(1010 , 0)
Open "C:\Mach3\OldState" For output As #1
Write #1, "Inch"
Else
Set UserLabel(1, "Metric")
Set UserLED(1012 , 0)
Set UserLED(1010 , 1)
Open "C:\Mach3\OldState" For output As #1
Write #1, "Metric"
End If
Close #1
and use this code for your macro m1010.m1s:
Sub init_units
On Error GoTo file_not_found
Open "C:\Mach3\OldState" For Input As #1
Input #1, unit
Close #1
If (StrComp(unit, "Inch") = 0) Then
setuserlabel(1, unit)
elseif (StrComp(unit, "Metric") = 0) Then
setuserlabel(1, unit)
Else
setuserlabel(1, "default")
End If
exit sub
file_not_found:
setuserlabel(1, "default")
End Sub
please replace the label text "Default" by Inch or metric, what ever you need.
Klaus