I am working on a program to help edit cnc g-code. My programs routinely grow to tens of thousands of lines. Also, I must deal with hundreds of legacy programs. As g-code is ancient and show no sign of ever being updated (think compatability), it is not user friendly. Fortunately most NC programmers will use line numbers in the form of N10, N300, N62 usually in that order as well, the cnc doesn’t care about these N lines.
My program reads the file into a list and shoves any line beginning with N into a combobox and adds info to another list used as an index to refer to the actual line number of the file. Upon clicking on an N Line in the combo box, I populate a second combo box with the entire ‘block’ of code.
Here is where I am failing, I want to be able to edit the code A Single Line at a time, this us crucial because it is too easy to press delete at the end of a line when opened in wordpad and delete the first command of the next line. This makes sparks, loud noise and never costs less that $100.
So, I have an edit (and insert) button on the form, which when clicked have the intent of altering the line and writing it back in it’s proper place in the list containing the code. Except, I am finding I cannot use the combobox position 0 as the pointer I have set up only works if I don’t click on the selected item in the 0 position, the effect is that I am writing a line prior to the one I want, the only line which can be edited by my scheme is the first line of the Block.
I am certain someone has already though of this and there is a better solution. I am attempting to use a checkedListBox but am finding it cumbersome.
Would anyone have a solution to my problem? I don’t need code, I’d rather figure it out on my own. I just need a roadmap and how to accomplish this.