Regex how to search in back direction in txt file?

21 views
Skip to first unread message

Timur

unread,
Nov 29, 2020, 8:24:51 AM11/29/20
to 4tH-compiler

Good day.

I have to make program-cnc (cnc it is just text with command with its coordinates) converter for CNC machine.

I found the good regex to search what I need. (but now I just checked it in notepad++ )

But I need here to modificate I and J coordinates as difference between X and Y coordinates that was before in file.

G00 X1341.4 Y123
G03 X1341.65 Y128.494 I1341.525 J125.747  <<-------- here we need to change I and J as the difference between the values X and Y that was before. So I need to search Xvalue Yvalue  going back from this point.

G03 X1341.054 Y117.511 I1341.4 J123
G03 X1341.4 Y117.5 I1341.4 J123
G03 X1341.496 Y128.499 I1341.4 J123

So question is   "how to go back to find another regex pattern?"

Thanks.

Timur





thebeez

unread,
Nov 30, 2020, 5:03:31 AM11/30/20
to 4th-co...@googlegroups.com
Hi Timur,

I'm not quite sure what you mean - do you mean the coordinates
themselves - or the
pattern you used to identify these coordinates?

Personally, if it were the coordinates, I'd buffer them. Either by a
variable -
or better on a (string) stack. In 4tH you also have the ability (using a
library)
to store certain points in a file. I used that one on KJOTS2GN.4TH to
"roll back"
if certain data structures weren't found.

Hope this gives you a few ideas. Don't hesitate to come back if you need
more
advise.

Hans Bezemer

Timur Aksenov

unread,
Dec 4, 2020, 12:28:22 PM12/4/20
to 4th-co...@googlegroups.com
Good evening.

Could you help.

I need to get a list of files in the current directory.  I also need to find out the name of the newest file in the current directory.  How to do it?

Timur




пн, 30 нояб. 2020 г., 13:03 thebeez <the...@xs4all.nl>:
--
You received this message because you are subscribed to the Google Groups "4tH-compiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 4th-compiler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/4th-compiler/5a17953ebd65aa99e78d679a21e1d072%40xs4all.nl.
Reply all
Reply to author
Forward
0 new messages