Workbench External Tools won't launch external .bat file

I have a .bat file that launches my TADS documentation search .jar file. The .bat file works from a command line, and I have a desktop shortcut pointing to it that launches the tool when I double click it.

But I cannot get it to work as a Workbench External Tool.

I add it by locating the .bat file in the Select Program File dialog that is launched by the … button associated with the Program field in the External Tools page of the Workbench options dialog.

But when I then try to launch the tool from the Tools menu, I get this in the Debug Log (Capture output to debug log window is selected in the Workbench Options dialog):

How do I make it work?



Perhaps a silly question, but is tadsDocSearch.bat in D:\dev\tads\resources\tools\ ?

Yes. As I said, I used the Workbench’s own file picker to select the .bat file location, I did not hand-type the path or file name.

And the .bat file works just fine when I double click the desktop shortcut that points to that same location.

As it so happens, I’d tried to do exactly the same thing before I read your post, with equal lack of success.

I can at least tell you how to get rid of the error message. When you go into the Workbench Tools->External Tools dialog, you need to copy the directory where you have the batch file into the Initial Directory box (in my case I have C:\Users\Eric\Documents\TADS 3\tadsDocSearch\search.bat in the Program Box and C:\Users\Eric\Documents\TADS 3\tadsDocSearch in the Initial Directory box). I then don’t get the error message - but I don’t see your search program come up either.

One guess I have is that programs run as Workbench external tools aren’t meant to run interactively, but rather to have a parameter passed to them (see the Arguments section of the external tools dialogue). I ran a quick test by writing the following TADS 3 program (bare T3 with no libraries):

#charset "us-ascii"
#include <tads.h>

 *   The main entrypoint - the T3 virtual machine calls this function to
 *   start the program running.  'args' is a list of strings giving the
 *   command-line arguments that the user specified, if any. 
    // put your program code here

And then compiling it as an .exe (to do that you need to delete the .txt file from the list under Resource Files, otherwise Workbench complains that it can’t open it). You can then add the resulting exe file as an external tool, set the starting directory to the location of the exe file, and select $(SelText) as the argument. If you then select some text in Workbench and click on the tool, you indeed get a TADS interpreter window open echoing the text you selected.

This suggests to me that you may be able to get your search tool to work if you can get it to accept an argument which is the word it then searches for, without stopping to ask for user input if an argument is supplied. It may then be possible to use the search tool from within Workbench by selecting the text for which you want to search, and then launching the tool. That said, I’m not at all confident that this is the answer.

If this doesn’t work, my quick experiment suggests that it would almost certainly be possible to write the search tool in TADS 3 (plain TADS3 without any game libraries). This is what I did for the docindex tool that indexes the library manual (you can find the source, not all that well commented, in my GutHub repo). To get round TADS 3 file permissions issue the TADS program would probably need to reside in the adv3Lite directory, but that would have the advantage that the relative paths to all the adv3Lite docs would be known (i.e., could be hard-coded) without the user having to set them up. If the TADS 3 program was supplied both as a t3 and an exe then on non-Windows systems the t3 version could still be used as a search tool.

That said, further experimentation suggests that while running a TADS 3 exe from Workbench in this way sometimes works, it tends to crash Workbench, so this may not be a full answer either!

No, didn’t work. I modified the search tool to accept a search term as launch argument, then modified the .bat file to take a command line argument and pass it on to the -jar launch.

Then I set the External Tools Arguments field to Selected Text. I still get a cannot find the file error message, though the debug log shows that the command line argument is working…

I opened a project, opened a .t file, selected HelloTopic, and then tried running the search tool from the
Tools menu. Workbench echos the selection, but no search tool window.

I even tried putting the .bat file in the same directory as the Workbench .exe (C:\Program Files (x86)|TADS 3). No luck.

And so, the search, as it were, continues.



…I tried setting the initial directory as you suggested, but I still get the error message.

If you leave the debug log shown, the Workbench will not add messages from subsequent attempts to run the search tool from the External Tools menu. You have to hide the log after each run (right click on the Debug Log tab). Then the Workbench will redisplay the log, with the error message from the current run appended to it. The log only seems to clear when you close then reopen the entire project.