Page 1 of 1

Search problem

Posted: Sat Aug 07, 2004 1:17 am
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

Posted: Sat Aug 07, 2004 3:02 am
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.

Search problem revisited

Posted: Sat Aug 07, 2004 7:19 am
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

Posted: Sat Aug 07, 2004 10:39 am
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"

Posted: Tue Aug 10, 2004 4:14 am
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

Posted: Tue Aug 10, 2004 1:37 pm
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?

search problem continues....

Posted: Thu Aug 12, 2004 5:02 am
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

Posted: Thu Aug 12, 2004 7:51 am
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 ^

Posted: Thu Aug 12, 2004 9:00 am
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

Posted: Thu Aug 12, 2004 3:15 pm
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.

Posted: Thu Aug 12, 2004 4:12 pm
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.

Posted: Thu Aug 12, 2004 5:59 pm
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

Posted: Thu Aug 12, 2004 9:26 pm
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.