I have this code I'm working on with some help from a friend.
I want to erase all of the "M02" (End of Program) lines in the NC file, except the last one, of course...
It is a combine NC file, but somehow, the post process writes an (End of Program) line after each (End of Sheet) line.
Here's the code:
Requires TASK.Selection
dim cncPath = "C:\Fabrication\DataBases\CF Metric 2017 - Rev3\CNC"
dim filename = "999-31105.cnc"
dim fileScan as FILELOCATOR
fileScan.Scan(cncPath, filename, true, false)
dim lp = 1
dim currentLine = ""
for lp = 1 to fileScan.FileCount
Object ncFile = new FILE(fileScan.File[lp], FORINPUT+ISTEXT)
Object newNcFile = new FILE(cncPath + "!999-31105.cnc", FOROUTPUT+ISTEXT)
newNcFile.Open()
while not ncFile.EOF
currentLine = ncFile.ReadLine()
Debug currentLine
if currentLine <> "M02" then
newNcFile.WriteLine(currentLine)
EndIf
EndWhile
ncFile.Close()
newNcFile.Position = FILE_END
newNcFile.WriteLine("M02")
newNcFile.Close()
REM- ncFile.Delete(TRUE)
next lp
The probleme I have, is the original file is read as expected, but the newfile is nowhere to be found.
Looks like it is not written at all.
I refreshed the folder, but it is simply not there.
Certainly, I'm missing something.
Any small bit of help would be greatly appreciated.
Thank you all,