Is it possible to call C++ functions via a DLL from TADS???

I know it’s unlikely but my text adventure project requires me to use a lot of C++ code I already have. This may sound odd but that is what I need to do. Is there anyway of doing this through TADS?

If not is there any other text adventure authouring engine that allows me to do this that anyone knows of?

Thanks in advance.


Your question lies well beyond the horizon of my competence area, but have a look at this page in the System Manual: This seems to suggest that when you’ve compiled your game using the WebUI features, Level 1 security will allow the game to access other programs on the same computer.

My question on it is what are you trying to do in your game that you feel you need C++ to suppliment Tads?

[Edited: sorry, deleted some suggestions. Had re-read the title of the post to realize you’re wanting to call DLL’s not EXE’s from Tads]

There’s this: to make your own Tads 3 libraries and bundle them with your Tads 3 executables. For example, calling a bunch of custom math functions. I’d think it would be easier to convert the C++ stuff to Tads 3 methods if that’s all you’re wanting to accomplish with external calls.

Also I saw this (I think for Tads 2):

2.2.5/MS-DOS patchlevel 1.0  08/24/98

  - The 32-bit Windows version of the run-time now supports external
    functions.  This applies to both the character-mode run-time (TR32)
    and the graphical HTML TADS run-time (HTMLTADS).

    The process of designing and coding your external function in C is
    the same as in past versions; refer to the TADS Author's Manual for
    a detailed description of how to write and call an external function.

    On Win32, external functions are implemented with DLL's (dynamic link
    libraries).  Each external function resides in its own DLL with the
    same name as the external function as given in the TADS source code
    of your game.  For example, suppose you define a function like this
    in your game's source (.t) file:

       myfunc: external function;

    In this case, the run-time will attempt to load a DLL file called
    MYFUNC.DLL (note that the Windows file system is case insensitive,
    so the case of your function's name is not significant for the
    purpose of loading the DLL file).

    To compile your external function, simply use the options or settings
    for your compiler to produce a DLL file from your .c file.  Note that
    your DLL must export the function "main".  Using Visual C++ version
    5.0 or later (and probably earlier, although we haven't tested these
    exact command line options with earlier versions), you can use the
    following command line to create a DLL from your .c file:

       cl /LD /I"TadsDir" testux.c /link /export:main /out:myfunc.dll

    In the line above, replace "TadsDir" with the path to your TADS
    executables directory; replace testux.c with the name of your .c
    source file; and replace myfunc.dll with the name of the DLL you
    wish to generate (which must be the same as the name of the external
    function as defined in your TADS source code file).

    The sample external function C code in TESTUX.C has additional
    information on the Win32 build procedure, including instructions
    for Borland C.

    At this time, there is no way to put a DLL into a .GAM file using
    the resource mechanism.  Each external function that your game uses
    must reside in a separate DLL file that you include with your game.

…from here: … so the answer is “yes you can do that.”

In Tads 3, from the search bar pointing to the user manuals, searching for “DLL” I found:


The language-mode features we just described are fully extensible with a plug-in system, in case you want to add support for another language you find useful within Workbench. The plug-in system uses DLLs containing COM objects - we chose that infrastructure because it lets you write these objects in virtually any programming language on Windows. We've provided a set of C++ classes that makes it relatively easy to write a plug-in in C++. If you're interested, refer to the "addins" directory for a bunch of source files that provide specifications and examples. The main file is itadsworkbench.h, which contains the specification of the plug-in interface. Also see wb_addin.h, which defines the framework classes. We've also supplied source code for the TADS 3 and HTML modes, both to serve as examples of how to build add-ins, and to make it easy to make minor tweaks to the behavior of those modes. Everything related to the add-ins is in the "addins" subdirectory of the main install directory.