How to update text in a file from a program (Tool)

General questions about using TextPad

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

Post Reply
SamBarr
Posts: 15
Joined: Wed Jan 28, 2004 3:28 pm
Location: Manhattan Beach, CA 90266
Contact:

How to update text in a file from a program (Tool)

Post by SamBarr »

I have a VB program that I call from TextPad using Tools (Ctrl+1).
I pass a parameter of '$Sel' which sends the selected text to
my program.

From the open text file I select text and then call the tool.
My VB program takes an action based on the selected text that was passed.

My question is:
From my program can I do anything to modify the text in the TextPad file ?
I would like to update the original text file based on logic in my program.

The only thing that I know of to update the text would be a macro but
I need to be able to modify the macro from time to time without having to
re-record the macro.

Thanks,
Sam
schnitzi
Posts: 19
Joined: Mon May 12, 2003 8:36 am

Re: How to update text in a file from a program (Tool)

Post by schnitzi »

Seems to me you would have to pass $File as well as $Sel. Then
have your program look for the selected text in the file, do whatever
modifications to it, then write the file back out. TextPad will then
warn you with something like "Another application has modified this
file; reload it?".

If you take this approach, you might want to also consider passing
$Col, $SelWord, or some of the other parameters as well, in order
to find the selected text better. And be sure to set "Save all documents
first" for your tool.
Post Reply