Lessons Learned Writing MathChat John Brewer 6/12/93 MathChat was my first MathLink program, and was very a much a learning experience for me. Here are some gotchas that I ran across using the MathLink API. The MathLink protocol is documented in at least 3 separate places: The MathLink Reference Guide, Major New Features in Mathematica 2.2, and the ReadMe file that comes with the MathLink distribution. Be sure not to overlook the New Features guide, as it covers many new features, and documents several previously existing but undocumented ones, such as MLConnect, MLName, and MLSetYieldFunction. The many preprocessor macros needed to provide cross platform compatibility render the header file virtually incomprehensible. You may want to run through the C preprocessor (by using the "Preprocess" command in Think C, for example) to produce a more human-readable version of the header file. Be sure to continue using the original in your programs to avoid any compatibility problems. Be sure to include the appropriate MathLink resources in your application! MathLink is robust enough to work without it's resource file under most circumstances (as users of MathChat 1.0d1 discovered :-), but is far more stable and user friendly when it has its resources. Calling MLOpen with an empty argument list will put up a series of dialogs letting the user select link settings. WHEN CALLING MLOPEN, BE SURE 'argc' AND 'argv' MATCH! It is especially easy for them to get out of sync as you add and delete arguments to MLOpen. You may want to use code like that in MathChat's OpenLink function to ensure that argc and argv always match. No declaration of the function passed to MLSetYieldFunction is given in the documentation. It should be declared as: int MyYieldFunction(MLINK whichLink, MLYieldParameters parms) I have no idea what MLYieldParameters contains.