Page 1 of 1

trouble with tool output

Posted: Sun Feb 08, 2009 3:46 am
by webber123456
I'm having trouble with tool output of TextPad (5.2).

I am unable to get the cursor to jump to the found line of the source file when double clicking a result line of the tool output.

Doubleclicking just displays at the bottom of the window "Cannot jump to item under the cursor."
sample output of the tool is;

Charts.cls(3): showmessage

How do I get this to return me to the line 3 ?

Posted: Sun Feb 08, 2009 11:06 am
by ben_josephs
You need to set the regular expression and registers to match your tool's output.

Using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
try something like
Regular expression to match output: ^([^(]+)\(([0-9]+)\):

Registers:
File: 1
Line: 2

Posted: Sun Feb 08, 2009 4:33 pm
by webber123456
thanks, that got it working.

What might be the combination if I wanted to reverse the sequence of the output to look like:

showmessage :Charts.cls(3):

Posted: Sun Feb 08, 2009 5:45 pm
by ben_josephs
.*:(([a-z]:)?[^(]+)\(([0-9]+)\)

Posted: Sun Feb 08, 2009 6:43 pm
by ben_josephs
Ah. There's a problem with that. It doesn't handle drive letters properly. If there will never be a drive letter at the front of the file name, use this:
.*:([^(]+)\(([0-9]+)\)
And if there might be a drive letter, you need to be precise about what exactly is the delimiter at the beginning of the file name.

Posted: Sun Feb 08, 2009 7:50 pm
by webber123456
excellent. :D

Now I can create a function list for the working file and use it to jump to any function.

I still am unclear as to why the registers are "1" and "2"

I know TP is looking to find the 'file' and 'line' but how is it reading these two values from the reg expr. ? It appears the expression is only finding the line number.

Posted: Sun Feb 08, 2009 8:23 pm
by ben_josephs
The regex contains two sets of capturing parentheses. The left parentheses are numbered from the left, starting at 1. The "register" numbered n holds the text that was matched by the nth parenthesised regular subexpression.

In Posix syntax, capturing parentheses are unescaped and literal parentheses are escaped. (In the default syntax it's the other way around.)

Code: Select all

   1        2
   |        |
   V        V
.*:([^(]+)\(([0-9]+)\)

Posted: Sun Feb 08, 2009 8:52 pm
by webber123456
thank you. that helps.

I couldn't find anything in the help file which explained that relationship.

Posted: Tue Feb 10, 2009 8:52 am
by nvj1662
Have you ever thought of writing a book, Ben? You certainly know you stuff! :wink:

Posted: Tue Feb 10, 2009 12:19 pm
by ben_josephs
Well, I know some of the stuff.

Anyway, someone who knows all of the stuff has already done it:

Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/

This is the reference for regular expressions.

But be aware that the regular expression recogniser used by TextPad is very weak compared with modern tools. So you may get frustrated if you discover a handy trick that works elsewhere but doesn't work in TextPad.