Home News Shopping FAQ Library Download Help Support
Contents : Technical articles
Writing EXE and DLL files for programmable components in SuperMemo 8 Piotr Metzler, Piotr Wozniak, February 1996

This specification shows you how you can develop programmed knowledge systems for SuperMemo 8. This extends the areas of applications of SuperMemo into procedural training, creativity, rehabilitation, and more. The DLL specification should be simple enough for any programmer to write simple programmed components (DLLs) for SuperMemo 8 knowledge systems. This shall break all limitations imposed on you imagination by standard repetition and knowledge representation mechanisms imposed by SuperMemo.

Caution! This specification is not compatible with SuperMemo 98. To execute your DLLs in 32-bit SuperMemo, you will have to recompile to the new specification (coming soon)

To add an EXE component to an element in SuperMemo 8, do the following:

  1. Create a programmed component by dragging it from the edit tab at the top of the element window (a button Execute should appear on the screen)
  2. From the created component pop-up menu choose Import file
  3. In the file browser dialog, choose the EXE file to import and click OK

The above sequence should make sure that you can execute the EXE file by pressing the Execute button. You can change the name of the button by choosing Button text on the component’s pop-up menu. For example by typing &Calculator and importing CALC.EXE from Windows, you can allow the user to execute the Windows calculator by choosing the Calculator button. Note that in this, a separate copy of the EXE file will be created within the knowledge system and deleting the calculator in Windows will not affect the behavior of the system.

To add a DLL component to an element in SuperMemo 8, act as with EXE components. Note that the DLL must be written specifically for SuperMemo 8, i.e. it cannot be just any DLL. The only difference here is that DLLs cannot be executed independently. Instead, SuperMemo 8 will call specific procedures coded in the DLL such as: Repetition, Edit, or Install.

To write a DLL that will work with SuperMemo 8, you should implement one or more of the following procedures (all procedures are optional!):

Repetition - called at the moment of executing the programmed component (e.g. by choosing the Execute button or calling PLAY in a script). If this procedure is not defined, no action is taken and no error is reported.

Edit - called only at the moment of choosing Editing mode on the programmed component pop-up menu and used, for example, to edit parameter files associated with the DLL. If this procedure is not defined, no action is taken and no error is reported. Note that the DLL can create only one parameter file within the knowledge system without calling allocation and registration procedures. This file has the same path and name as the DLL file; only its extension is PAR. All other files created by the DLL within the knowledge system should be properly registered with the system by means of procedures available from KSI.DLL (Knowledge System Interface) described later.

Install - called only at the moment of importing the DLL file into the knowledge system. If this procedure is not defined, no action is taken and no error is reported. This is the best procedure to place a code creating and initializing the parameters file associated with the DLL.

All the above procedures use only one parameter: pointer to a record called RepDat. This record can be used to pass parameters to and from the DLL. The definition of RepDat is as follows:


The interpretation of the fields is as follows:

The specification of TRepDat is open so that new fields can be added in the future as needed. In particular all learning parameters and metrics can be obtained from TRepDat (see updates to this document in the future). The open specification also means that you, DLL developer, can also postulate new fields that are needed in your implementation. Those fields can be filled out in future specifications.

Most of the fields of TRepDat are set by SuperMemo upon executing relevant DLL procedures. The author of the DLL does not have to make use of those fields, nor does he have to set output fields! No errors will result.

Procedures available from KSI.DLL (Knowledge System Interface) can be used in communicating with SuperMemo 8 while executing a DLL associated with a programmed component. You can download free update to the newest version of KSI.DLL from the paragraph at the bottom of this page. Here are some useful examples of procedures available from KSI.DLL.

  1. procedure PlayComponent(ItemNo:longint;CompNo:byte); export;
    Used to play or execute the component associated with the element ItemNo and component CompNo (both can be viewed with the button displaying component number tags on the Edit tab in the element window). The component can be sound, video, script or a programmed component.
  2. procedure GetNewFilename(filename:PChar); export;
    Used to obtain new legal filename within the knowledge system (without extension!)
  3. procedure RegisterSound(filename,itemname:PChar;var Posit:longint); export;
    Used to register a wave or midi file used by the DLL. Filename is the filename obtained from GetNewFilename with a proper extension added. Itemname is any name under which the registered sound will appear in the sound registry. Posit is the newly allocated registry position for the registered sound file. Use Posit with GetSoundFilenameFromPosition if you want to make sure you use the updated sound file registered at that position (the user might wish to change the sound registered by your DLL). The var parameters indicates that Posit is an output parameter here
  4. procedure GetSoundFilenameFromPosition(Posit:longint;filename:PChar); export;
    Used to obtain the name of the file registered under a given position in the sound registry. Posit is the position. Filename is the returned filename
  5. procedure RegisterImage(filename,itemname:PChar;var Posit:longint); export;
    Analogous to RegisterSound.
  6. procedure GetImageFilenameFromPosition(Posit:longint;filename:PChar); export;
    Analogous to RegisterImage.

For example, to add a new sound file to the knowledge system do the following:

  1. Call GetNewFilename from KSI.DLL to obtain a new legal filename within the knowledge system (the filename does not have an extension).
  2. Copy the sound file to the filename obtained in the previous step (do not forget to add an appropriate extension)
  3. Register the sound file by calling RegisterSound. Provide the new sound file name used in the previous step as filename. Use any name as itemname, e.g. ‘My sound’ (this name will later appear in the sound registry).

To write the simplest DLL for SuperMemo 8 that displays a Hello world dialog, do as follows:

  1. Implement and publish the Repetition(RepDat:pointer) procedure in your DLL.
  2. Display Hello world dialog within the Repetition procedure.
  3. Ignore RepDat parameters.
  4. Ignore Install and Edit procedures, i.e. do not bother writing anything.
  5. Compile your DLL and import it to any knowledge system as described earlier.
  6. Click the Execute button. Hello world should appear on the screen.

You can download the newest version of KSI.DLL from here: Download KSI.ZIP (73 KB, May 22, 1997).

If you have further questions, do not hesitate to write to SuperMemoMail. Come back to this page for specification changes and updates to the KSI.DLL. If you would like to (1) contribute to the development of programmed DLL modules for SuperMemo 8, (2) propose a specification extension or (3) submit a freeware DLL or EXE send your propositions to SuperMemoMail