HELP HOW TO INSERT text into blank lines with macro
-
i am trying to create a macro to replace lines in 2 different g codes.
i am almost there.
my last problem is. i have a line that i need to insert a blank space below it and add text into it.
i can find the line by finding letters in it.
i can create a blank line under it, but i cant find a way to add text to that line.
this needs to be all doable in macro as there is a few times it needs to repeat the process.
is there a way to insert txt into blank lines under macro?
or better
as in find and replace, is there a way to do find text then add a blank below and add text to it.
your knowledge would be very much appreciated -
@Steve-Trevella said in HELP HOW TO INSERT text into blank lines with macro:
your knowledge would be very much appreciated
I would be doing what you require using a regular expression (regex). You seem to already be familiar with the Replace function.
So a suitable regex for your situation would be:
Find What:(?-s)(text i want to find.?)
Replace With:${1}\r\ntext I want to insert
Search mode is regular expression.So this finds the text you are looking for (obviously you need to replace the text I’ve used with your look for and inserted text) and continues to capture to the end of line (excluding the line feed/cariage return). The replace portion inserts a new line feed/carriage return, then the new text. The original line feed/carriage return is still there and now appends the new line inserted.
And as you refer to a macro, which is just the keystrokes recorded of the replace function with the fields as described above.
If this doesn’t suit you might have to provide an example as some of what you say isn’t entirely clear.
Terry
-
@Terry-R thanks for your reply.
i have a line. for example
g0 x26 y68
g1 x45 y67
i want to add M10
between those 2 lines
this needs to happen a few times
the only common character is g0,
with the find i worked out with each g0 i can create a empty line below it
but can not see how to add m10 to that space line using the macro.
there may be 20 to 50 times in each file so macro is the way i need to do it.
i am not familiar with the stuff… i have managed to work out how to find and replace all the other lines that need to change… but this has me stumped?? -
So did you try my solution? Just enter g0 in place of the “text I want to find” and the m10 in place of the “text I want to insert”. Don’t forget the search mode must be “regular expression”.
Try it on a copy of the file and find next, then replace buttons just so you can see what is happening.
Terry
-
I’d try:
Find:
(?-is)^g0.*(\R)
Replace:$0M0$1
Search mode: Regular expressionAlso, you can’t just say
M10
one place in what you want, andm10
in another – this just shows us that you can’t pay close attention to detail, and makes it harder to help you. :-( -
-
@Steve-Trevella
You aren’t reading the solutions at all. Search mode is “regular expression” not “normal”!Also you could remove the tick boxes on match whole words and match case.
Terry
-
You aren’t reading the solutions at all.
This is true.
And the attention-to-detail aspect is getting worse, not better. :-(
We can’t help those that won’t help themselves.Notes:
g0
suddenly somehow becameG00
- no one said to use
\r
in the Replace without a\n
following - it sure looks like there is a space between
(?-s)
andG00
in the Find
-
@Alan-Kilborn said in HELP HOW TO INSERT text into blank lines with macro:
$0M50
HI THANKYOU.
I CAN MAKE THAT WORK!!
MUCH APPRECIATED