trouble with tool output

General questions about using TextPad

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

Post Reply
User avatar
webber123456
Posts: 50
Joined: Wed Jul 30, 2003 2:55 am

trouble with tool output

Post 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 ?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
User avatar
webber123456
Posts: 50
Joined: Wed Jul 30, 2003 2:55 am

Post 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):
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

.*:(([a-z]:)?[^(]+)\(([0-9]+)\)
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
User avatar
webber123456
Posts: 50
Joined: Wed Jul 30, 2003 2:55 am

Post 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.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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]+)\)
User avatar
webber123456
Posts: 50
Joined: Wed Jul 30, 2003 2:55 am

Post by webber123456 »

thank you. that helps.

I couldn't find anything in the help file which explained that relationship.
nvj1662
Posts: 53
Joined: Thu May 17, 2007 10:02 am

Post by nvj1662 »

Have you ever thought of writing a book, Ben? You certainly know you stuff! :wink:
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
Post Reply