Tool output registers & need help

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Ben Voris

Tool output registers & need help

Post by Ben Voris »

The tool preferences refers to "Registers" for File, Line, and Column. I can't find these documented. By looking at the examples, I guess that the registers are from tagged regular expressions. That is "register 1" is comes from the first tagged regular expression. Do I have that right so far?

If so, can you help me with setting up a tool? The tool outputs a series of alphanumeric characters (with no white space), one or more spaces, a fully qualified filename, one or more spaces, and a line number.

The Posix regular expression I've set up is:

^.* (.*) ([0-9]+)

With Register File = 1, Register Line = 2, and Register column = blank.

I've set Capture Output, Supress Output until completed, and Sound alert when completed. When I click out an line in the Command Results window, I get a status line entry of "Cannot jump to item under the cursor". The filename is valid in so far as I can copy-and-paste it into into the open menu and can open it. The line number is correct if I use control-G to jump to it.

Any ideas?
Jens Hollmann

Re: Tool output registers & need help

Post by Jens Hollmann »

Are you really using POSIX regular expressions? if so I can't see anything wrong with your regexp. Otherwise use "\(" and "\)"instead of "(" and ")".

There is an easy test: Cut and paste your tool output into a new file, so that you can search and replace. Then do a search and replace with your regexp as a search pattern and replace with something like:

file: "\1" line: "\2"

Then you can easily see what TextPad would do to the tool output when searching for a jump target.

Mind that you must close the output window and restart the tool when you change the regexp in your settings!

HTH

Jens
Ben Voris

Re: Tool output registers & need help

Post by Ben Voris »

In "Editor", "Preferences", "Use POSIX regular expressions syntax" is checked.

Thanks for the tip about testing with Replace. Sure enough, I get the error, "Cannot find regular expression." The text I captured looks like:
"foo::bar c:\myfile.txt 217". The white space happens to be tabs, but I get the same result when the tab is replaced by a single space. I also get the same error if I do a Find instead of a Replace.

Regar

Texpad version is 4.6.

Any other ideas?
Jens Hollmann

Re: Tool output registers & need help

Post by Jens Hollmann »

I tried this with search and replace on your example:
search for:
^[[:graph:]]+[[:blank:]]+([[:graph:]]+)[[:blank:]]+([[:digit:]]+)
replace with:
File "\1" Line "\2"

Works fine for me. I switched to POSIX-regexp for the test too. So I would say this regexp should do the trick. If not post your exact search and replace expression.

[:blank:] matches spaces and tabs, so that shouldn't be a problem.

Regards

Jens
Ben Voris

Re: Tool output registers & need help

Post by Ben Voris »

Thank you for the answer; it does work. I don't fully understand your regexp. Could you explain it?

Thanks again.
pgwilliams
Posts: 6
Joined: Thu Mar 20, 2003 2:34 am

Tool output registers and regular expressions

Post by pgwilliams »

Hi Ben and Jens, found your postings very helpful and I was able to get quite a long way forward. But now I'm stuck.

I have the (java execuatable) output:

Starting
java.lang.Exception: Foo Exception
at hello_exception.main(hello_exception.java:5)
Exception in thread "main"
Tool completed with exit code 1

Which I'm trying to pull out using the regular expression:
(\(.*\):\(.*\)) with file 1, line 2

Using your trick of doing a search and replace in an identical text file I correctly get File: 'hello_exception.java' Line: '5' inserted

However when I double click on the error I'm still getting "Cannot jump to item under cursor"

This isn't a problem with jumping to compilation errors - I suspect that's because they give the full path to the file in the output, where a java exception only gives the filename.

Can anyone assist?
Regards,
Peter
pgwilliams
Posts: 6
Joined: Thu Mar 20, 2003 2:34 am

Post by pgwilliams »

Sorted - you need to match the entire line

(\(.*\):\(.*\))

just matches the portion I need which is why it works with search and replace, but I need .*(\(.*\):\(.*\)) to allow that first part of text to match also.

Cheers!
Peter
drxenos

Re: Tool output registers & need help

Post by drxenos »

Ben Voris wrote: The Posix regular expression I've set up is:

^.* (.*) ([0-9]+)

Any ideas?
Your problem is that regular expressions are "greedy." The first ".*" will eat everything up to the final two spaces, and the "(.*)" will match nothing. for example ($=space):

Bob$jeff$123
this would work, 1="jeff", 2 = "123"

Bob$jeff$$123
this would not, 1 = "", 2 = "123"
Post Reply