Darth Yoda Posted October 15, 2011 Member ID: 934 Group: **- Inactive Registered Users Followers: 19 Topic Count: 131 Topics Per Day: 0.03 Content Count: 832 Content Per Day: 0.16 Reputation: 137 Achievement Points: 5656 Solved Content: 0 Days Won: 0 Joined: 12/27/09 Status: Offline Last Seen: November 19, 2014 Birthday: 08/16/1960 Share Posted October 15, 2011 I do CNC programming and have a lot of programs that need to be tidied up for efficiency. I can manually edit all the files in notepad but it takes a long time. Notepad++ is a programmers helper with many great features dedicated to programming. I need to search and replace a string. Easy enough.....Find "G" replace with "ERG" or somesuch. I need to do a multiple search and replacement based on the found text. Example: A couple lines of code reads % this clears the machine memory and is always on the first line. N1P00106123 the first N and number is the line number P is program number always on the second line N136G60X23.44Y1.34 G is a code that moves the machine X and Y are direction and distance codes. N137F4 F4 is the speed N138M00 M is a control character N139G71X22.890Y3.789 I need to add a space before the P G M or F on each line. I can but I have to run four search/replace routines. I would like to do one search/replace to save time. Can I search P|G|M|F and return a spaceP or spaceG etc. depending on whether a G M P or F is found? Or better can I search N137G or N1P and replace with spaceG or other depending on the find? If I get either of these to work can I renumber the lines AND do the search/replace after I modify the programs? I have played a couple days with it and searched the web quite well but can't get it sorted. I have made a macro that does part of it but would like to find a one click solution if possible. Thanks again guys for your help. Link to comment Share on other sites More sharing options...
sabreeyes Posted October 15, 2011 Member ID: 1642 Group: **- Inactive Registered Users Followers: 22 Topic Count: 72 Topics Per Day: 0.01 Content Count: 900 Content Per Day: 0.18 Reputation: 241 Achievement Points: 6952 Solved Content: 0 Days Won: 0 Joined: 08/05/10 Status: Offline Last Seen: June 3, 2016 Birthday: 07/30/1958 Share Posted October 15, 2011 is that a CNC lathe or mill, I was a michanist a long time ago, but not CNC Link to comment Share on other sites More sharing options...
Darth Yoda Posted October 15, 2011 Member ID: 934 Group: **- Inactive Registered Users Followers: 19 Topic Count: 131 Topics Per Day: 0.03 Content Count: 832 Content Per Day: 0.16 Reputation: 137 Achievement Points: 5656 Solved Content: 0 Days Won: 0 Joined: 12/27/09 Status: Offline Last Seen: November 19, 2014 Birthday: 08/16/1960 Author Share Posted October 15, 2011 It's actually 3 machines.... plasma, laser and punch. Link to comment Share on other sites More sharing options...
sabreeyes Posted October 15, 2011 Member ID: 1642 Group: **- Inactive Registered Users Followers: 22 Topic Count: 72 Topics Per Day: 0.01 Content Count: 900 Content Per Day: 0.18 Reputation: 241 Achievement Points: 6952 Solved Content: 0 Days Won: 0 Joined: 08/05/10 Status: Offline Last Seen: June 3, 2016 Birthday: 07/30/1958 Share Posted October 15, 2011 cool, the plasma, is that for cutting. What kind of work do you do Link to comment Share on other sites More sharing options...
Darth Yoda Posted October 16, 2011 Member ID: 934 Group: **- Inactive Registered Users Followers: 19 Topic Count: 131 Topics Per Day: 0.03 Content Count: 832 Content Per Day: 0.16 Reputation: 137 Achievement Points: 5656 Solved Content: 0 Days Won: 0 Joined: 12/27/09 Status: Offline Last Seen: November 19, 2014 Birthday: 08/16/1960 Author Share Posted October 16, 2011 We makeall sorts of parts for other companies. Our biggest contract is with Catapillar making HUGE underground mining equipment. Our second is frak tanks for the oilfield industries. Then many oddparts as needed. I have to program 6-7 programs a day and getting them to run efficiently in our antique ways is reDIKulous. Yes the plasma and laser are both for cutting. Link to comment Share on other sites More sharing options...
WHITEBOY Posted October 16, 2011 Member ID: 171 Group: **- Inactive Registered Users Followers: 51 Topic Count: 65 Topics Per Day: 0.01 Content Count: 1487 Content Per Day: 0.28 Reputation: 443 Achievement Points: 8690 Solved Content: 0 Days Won: 1 Joined: 09/02/09 Status: Offline Last Seen: July 28, 2018 Birthday: 05/05/1970 Share Posted October 16, 2011 I never did any programing...but operated plenty of Lathes, Mills, and Universal Milling Machines. We did allot of work for Applied Materials, and other Semiconductor Companies like Texas Instruments. Is it Fanuc Controls your dealing with Yoda..? Link to comment Share on other sites More sharing options...
ChknFngr Posted October 17, 2011 Member ID: 922 Group: ***- Inactive Clan Members Followers: 72 Topic Count: 149 Topics Per Day: 0.03 Content Count: 3472 Content Per Day: 0.66 Reputation: 1286 Achievement Points: 23224 Solved Content: 0 Days Won: 1 Joined: 12/23/09 Status: Offline Last Seen: November 16, 2021 Birthday: 10/01/1975 Share Posted October 17, 2011 im using sublime for programming, it has a few options for search/replace, not sure it will do what u need, but u can try. http://www.sublimetext.com/ Link to comment Share on other sites More sharing options... Awards
Ph4nt0m Posted October 17, 2011 Member ID: 1 Group: **- Inactive Registered Users Followers: 39 Topic Count: 162 Topics Per Day: 0.04 Content Count: 1909 Content Per Day: 0.42 Reputation: 121 Achievement Points: 11489 Solved Content: 0 Days Won: 1 Joined: 12/06/11 Status: Offline Last Seen: January 4, 2020 Birthday: 06/28/1975 Share Posted October 17, 2011 You can do a regular expresion replace in Notepad++, I'm currently at work but will take a look tonight for you, Link to comment Share on other sites More sharing options...
Nutcutter Posted October 17, 2011 Member ID: 1540 Group: **- Inactive Registered Users Followers: 13 Topic Count: 40 Topics Per Day: 0.01 Content Count: 856 Content Per Day: 0.17 Reputation: 100 Achievement Points: 4812 Solved Content: 0 Days Won: 0 Joined: 06/28/10 Status: Offline Last Seen: May 6, 2017 Birthday: 09/20/1969 Share Posted October 17, 2011 Look in the plug-ins there is one I use that highlights the matches as you build the string, and I think another that helps you write it but I dont have it on this PC. Link to comment Share on other sites More sharing options...
Ph4nt0m Posted October 17, 2011 Member ID: 1 Group: **- Inactive Registered Users Followers: 39 Topic Count: 162 Topics Per Day: 0.04 Content Count: 1909 Content Per Day: 0.42 Reputation: 121 Achievement Points: 11489 Solved Content: 0 Days Won: 1 Joined: 12/06/11 Status: Offline Last Seen: January 4, 2020 Birthday: 06/28/1975 Share Posted October 17, 2011 Ok, try this, In notepad++ hit ctrl and F to open the search dialog, Click the replace tab to open the replace dialog, In the box that says "Find What" enter the following without the speach marks: "([GMPF])" In the box that says "Replace With" enter the following without the speach marks: " \1" In the "Search Mode" choose "Regular Expresion" NOTE!! In the replace with box, their is a space in front of the back slash, this is what tells notepad to add a space so this is very important.. If you add it correctly it should search for all instances of either G M P F and add a space in front of any instance that it finds So if you do it correctly it should turn this: Into this Link to comment Share on other sites More sharing options...
Darth Yoda Posted October 21, 2011 Member ID: 934 Group: **- Inactive Registered Users Followers: 19 Topic Count: 131 Topics Per Day: 0.03 Content Count: 832 Content Per Day: 0.16 Reputation: 137 Achievement Points: 5656 Solved Content: 0 Days Won: 0 Joined: 12/27/09 Status: Offline Last Seen: November 19, 2014 Birthday: 08/16/1960 Author Share Posted October 21, 2011 Yes Fanuk Ap5la on a Apelio II. Link to comment Share on other sites More sharing options...
Darth Yoda Posted October 21, 2011 Member ID: 934 Group: **- Inactive Registered Users Followers: 19 Topic Count: 131 Topics Per Day: 0.03 Content Count: 832 Content Per Day: 0.16 Reputation: 137 Achievement Points: 5656 Solved Content: 0 Days Won: 0 Joined: 12/27/09 Status: Offline Last Seen: November 19, 2014 Birthday: 08/16/1960 Author Share Posted October 21, 2011 In the box that says "Find What" enter the following without the speach marks: "([GMPF])" In the box that says "Replace With" enter the following without the speach marks: " \1" This was the part I needed. Thanks guys! Also the newest version of notepad dropped the textFX drop downs but they can be replaced by dragging the textFX dll into the right folder. Link to comment Share on other sites More sharing options...
Recommended Posts