Search problem

General questions about using TextPad

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

Post Reply
mover
Posts: 9
Joined: Sat Aug 07, 2004 1:10 am

Search problem

Post by mover »

I am a relative newcomer to Textpad. Would like to know if there is any way to give textpad a list of words and get it to mark lines containing it in a specific file which is open.

An example should clarify what I have in mind. I have a file called wordslu.txt containing 10 words, one word to each line. I have a dictionary file called dict.txt with headwords and meanings, one to a line. I want to search the dict.txt for words in wordslu.txt and mark lines containing the words. Thanks in advance.
Mover
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

I'm sorry but I don't believe TextPad will be able to help you on this one. I'm not really sure if any editor would come to think of it. Perhaps someone will think of a solution I'm not seeing.
I choose to fight with a sack of angry cats.
mover
Posts: 9
Joined: Sat Aug 07, 2004 1:10 am

Search problem revisited

Post by mover »

Is it possible to run an external program on the contents of an opened file in textpad and output results to the search window or cause matches to be marked in the open file? Thanks in advance.
Mohan Chunkath
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

In the find dialog, make sure Regex is selected (Posix syntax should be selected in Preferences
enter

your|list|of|words

in the Find What box and click on "Mark all"
mover
Posts: 9
Joined: Sat Aug 07, 2004 1:10 am

Post by mover »

Thanks MudGuard. The problem with the suggested solution is that it cannot handle a really long list of words. My example had only a few words but i would like to use a file with regular expressions. Thanks in advance.
Mover
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I just concocted an alternation of 500 names

Code: Select all

name001|name002|...|name500
from a big list. This regex is > 4000 characters long, and it works fine. I know it stops working if it gets too big, but is 500 words not enough for your purposes?
mover
Posts: 9
Joined: Sat Aug 07, 2004 1:10 am

search problem continues....

Post by mover »

Thanks ben for your posting...I am afraid 500 words is not enough..typically i have lists which are about 1000 words long with an average of 8 letters...add 3 characters for \|^...for each word as i want to mark only headword entries...i do run into a problem...The best workaround has been to use agrep as an external program and capture output in the command results window...does not mark the original file though..Thanks once again...
mover
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Switch to Posix Syntax and you get rid of the \ before the |.
Use ^(list|of|words) instead of ^list|^of|^words and you get rid of most of the ^
mover
Posts: 9
Joined: Sat Aug 07, 2004 1:10 am

Post by mover »

thanks. mudguard's suggestion saves several keystrokes..related question..anyway that an external program can be used to bookmark lines in the main window?
mover
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

I'm not sure about that one but since you don't seem to object to external programs, what about a simple tool that takes two files (one being the words used and the other your master list), finds the intersection between the two and then outputs the regex that you can then plug into TP to bookmark all. Cheesy, very cheesy but it could get you...

Hmmmmm, that got another thought going. I was wondering what would happen if the number of matches exceeded the length of the search dialog and I was going to suggest splitting it in N partitions and running it for each partition but then I thought what about AutoIt. I really need to look at it especially since I haven't seen cyberslug post for a while. At any rate, it's a macro scheduler program that you can basically set up to open any application and execute keystrokes. So my final thought would be to write a quick script that'll compare the two files and generate the list of words found in both. Take that list and build a command script for autoit and then run autoit to open the dictionary file and bookmark all the found lines.

Doable or too much work outside of TP? The script for the comparison is in my head already especially if Sets work as beautiful in Python as I think they will.
I choose to fight with a sack of angry cats.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I did not respond to original request because I could not see a TextPad only solution, as I understood the problem. If third party tools are an acceptable option, then my first thought was to use Macro Scheduler which I use frequently with TextPad.

Could read your dictionary file, paste the words into TextPad searches, do what you want with results, and continue through all words in dictionary.

I also use AutoIt, but think you will find Macro Scheduler much easier to work with.
Hope this was helpful.............good luck,
Bob
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Good point, you could completely eliminate the need to write a separate program to parse the file if you use either tool I suspect.

It'd still be fun to write the program though
I choose to fight with a sack of angry cats.
Kevin
Posts: 28
Joined: Tue Apr 01, 2003 7:55 pm

Post by Kevin »

How about adding the words to a syntax definition file? The words may not be marked (do you mean bookmarked?) but at least they would be color coded.
Post Reply