Need Help Editing Text to Correct Post Processor

I've gone as far as I can with Vectric Cut2D customizing a post processor in order to adapt a CNC Plasma Cutting System to a CNC Router cutter. Due to compatibilities issues between those two applications I need to correct the output from the post processor beyond what I can customize within Vectric Cut2D itself. I was hoping someone here might be able to help me generate a C++ program that would edit the text files to generate the G-code in the format I need.

I am hoping to write a C++ file that I can import the g-code text, and it will remove any instances of a empty "G1" "G22" when they are not followed immediately by any other text . I also need the program to insert a "G24" directly before any stand alone Z command such as "Z-.5000" Otherwise I need it to ignore the otherwise inoffensive text and output a new text file or overwrite the original Please see below, "Before" being the original post and "After" having been revised manually to read as desired.

For example:
//BEFORE//

G22Z-1.0000F10.0
G1
G22F40.0
G1X1.5000
G2X1.6250Y1.5000I0.0000J-0.1250
G22
G1Y1.2359

Z-0.5000
Y0.7359

G22Z-1.0000F10.0
G1
G22F40.0
G1Y0.5000
G2X1.5000Y0.3750I-0.1250J0.0000
G22
G1X1.2472


Should Read:
//AFTER//

G22Z-1.0000F10.0
G22F40.0
G1X1.5000
G2X1.6250Y1.5000I0.0000J-0.1250
G1Y1.2359

G24Z-0.5000
Y0.7359

G22Z-1.0000F10.0
G22F40.0
G1Y0.5000
G2X1.5000Y0.3750I-0.1250J0.0000
G1X1.2472


Thanks guys, I appreciate any help you can provide,
Chris Fern
Topic archived. No new replies allowed.