Apple script to convert GRBL to code that mach 3 and Ethernet smooth stepper will read and be able to control power. You can modify the Command to whatever you want/need it to be for your specific program.
I hope this helps someone else on here.
– Choose the file to be modified using the Finder
set chosenFile to choose file with prompt “Choose a file to modify:”
set fileReference to open for access chosenFile with write permission
– Initialize variables
set modifiedLines to {}
– Define the text to be inserted
set insertLineAbove to “M10P2”
set insertLineBelow to “M11P2 S10”
– Read and process the file line by line
try
– Read the file line by line
set eofReached to false
repeat until eofReached
try
– Read the current line
set currentLine to read fileReference until "
"
– Check if the line contains “G0”
if currentLine contains “G0” then
– Add M10P2 one line above the G0 command
set end of modifiedLines to insertLineAbove
set end of modifiedLines to currentLine
– Add M11P2 S25 one line below the G0 command
set end of modifiedLines to insertLineBelow
else
– Keep the line unchanged
set end of modifiedLines to currentLine
end if
on error
– End of file reached
set eofReached to true
end try
end repeat
– Close the file
close access fileReference
– Combine the modified lines into a single string
set modifiedText to (items 1 thru -2 of modifiedLines) as text
– Write the modified text back to the file
set fileReference to open for access chosenFile with write permission
set eof of fileReference to 0
write modifiedText to fileReference
close access fileReference
display dialog “File successfully modified and saved.” buttons {“OK”} default button “OK”
on error errMsg
– Handle any errors that occur
try
close access fileReference
end try
display dialog "Error: " & errMsg buttons {“OK”} default button “OK”
end try