Script needs to wait for editing to be complete

General questions about using TextPad

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

Post Reply
Rich Pasco

Script needs to wait for editing to be complete

Post by Rich Pasco »

Usually, I want invoking TextPad when it is already running to open the file named on its command line in the existing instance. To achieve this I have unchecked "Allow multiple instances to run" at Configure/Preferences/General. Thus the second instance quits immediately after having handed off the file to the original instance.

Sometimes I call TextPad from a shell script (BAT file). In this case, I would like the script to wait until I have saved the file and closed its edit window--although not necessarily quit TextPad as a whole, since I may have other files open in it.

Is there a way to achieve this without changing the "Allow multiple instances to run" setting? For example, I would like my shell script to contain

textpad -wait filename.txt

which means that the script is not to continue until I close the edit window on that file.

Of course, if I were to check "Allow multiple instances to run" then my script could contain

start /w textpad.exe filename.txt

which would achieve almost what I want, except that now I would be opening every file in a separate TextPad session, which is not what I really want.

- Rich
Rich Pasco

Re: Script needs to wait for editing to be complete

Post by Rich Pasco »

I discovered something that allows me to answer my own question.

The Help file, under Reference Information / Command-line parameters, tells about the "-m" option, which means to "Start another instance, regardless of the setting for 'Allow multiple instances.'"

With this option, my script can contain

start /w textpad.exe -m filename.txt

which will start a new instance with just filename.txt and wait for the user to close that instance before proceeding.

- Rich
Post Reply