Writing scripts to add life to SuperMemo elements

The script component makes it possible to use a simple script language to manipulate other components in a given element (i.e. to display components, change their position, animate them, use them in learning tests, etc.). This way you can create interactive presentations, animation, video subtitling, drag-and-drop tests, hyperlinks to the Internet, e-mail links, etc.

To create a script do the following:

  1. create an element with contents of your choice (components, their position, their attributes, etc.)
  2. add a script component from the Compose toolbar (i.e. click the component button and two locations in the element area)
  3. right-click the script component and choose the Script option on the component menu
  4. write the script program (see below) and choose OK

While writing the script, use the script editor's context menu that makes it possible to insert full command syntax into the editor (right-click the editor to open the menu).

For example, to repeatedly play music from a sound component number 3 (see below), you could write:


To view component number tags click 148 speed-button on the Compose toolbar, or choose Components : Component order (Shift+Ctrl+O) on the element menu. Note, that when you right-click within the element window, you will either open a component menu (if you click over a component) or the element menu (when you click an empty area within the element).

The best way to learn more about scripts is to inspect scripts in multimedia collections shipped with SuperMemo, e.g. Cross Country, Video English, Easy English, etc. Use Search : Other registries : Script to inspect scripts. Alternatively you can download a free collection Advanced Tests with SuperMemo from SuperMemo Library for some simple examples.

Important: apostrophe is reserved in scripts for delimiting string variables. If you need to include an apostrophe in a string, use a backquote instead. For example:

TEXTOUT 3 'I`m delighted to have met you'

Script commands used in SuperMemo

  • Execute
    • To display another element of the collection use Element (Ctrl+E) with the number of the element as the argument.
      Syntax: ELEMENT <Number>
    • To change the flow of script execution use Goto (Ctrl+G) with script label or script line as an argument.
      Syntax: GOTO <Label>|<Line>
    • To jump to a particular label in the script you need to define the label with Label.
      Syntax: LABEL <Name>
    • To display a message or warning use Message.
      Syntax: MESSAGE <Text>
  • Internet
    • To make the users send an e-mail use MailTo.
      Syntax: MAILTO <Address> <Subject> <Body text> <Name>
    • To make SuperMemo display a selected page from the world wide web, use URL.
      Syntax: URL http://<web address>
  • Learn
    • To dismiss the currently displayed element use Dismiss.
      Syntax: DISMISS
    • To simulate the learning procedure (as if the user pressed the button Learn) use Learn (Ctrl+L).
      Syntax: LEARN
  • Playing
    • To execute a frame of an animation sequence, use Frame. The <Component> argument specifies the image component within which the animation is executed (alternatively, BACKGROUND can be used to execute animation in element entire background). <Image Registry member> indicate the image that makes up the executed frame.
      Syntax: FRAME <Component>|BACKGROUND <Image Registry member>
    • To play a sound, video, script or execute a binary object, use Play (Ctrl+P).
      Syntax: PLAY <Component> <Registry member>
    • To play a sound or video without suspending the execution of the script use Start (Ctrl+T).
      Syntax: START <Component>
    • To stop the script use Stop.
      Syntax: STOP
    • To play user recorded sound in the sound component use UPlay (to display the recorder panel in sound components check Sound : Panel : Recorder on sound component menu).
      Syntax: UPLAY <Component>
    • To suspend the execution of a script for a number of milliseconds use Wait (Ctrl+W).
      Syntax: WAIT <Milliseconds>
    • To suspend the execution of a script until a given frame is displayed in a video sequence, or until a given position is reached in a sound track, use WaitFrame with the frame or position as an argument.
      Syntax: WAITFRAME <Component> <Frame>
  • Showing
    • To display a given registry image in an image component use Display (Ctrl+D). Its first argument is the number of the image component in the element. Its second argument is the name of the image registry member.
      Syntax: DISPLAY <Component> <Image registry member>
    • To change a font in a text, sound or Spell-Pad component, use Font (Ctrl+F).
      Syntax: FONT <Component> <Font registry member>
    • To hide a component use Hide (Ctrl+H).
      Syntax: HIDE <Component>
    • To move a component to a new location use Move.
      Syntax: MOVE <Component> <X> <Y>
    • To show a hidden component, use Show (Ctrl+S).
      Syntax: SHOW <Component>
    • To display a particular text in a text component use TextOut (Ctrl+X).
      Syntax: TEXTOUT <Component> '<Text>'
    • To change the display status of a component (from hide to show, or from show to hide), use Toggle.
      Syntax: TOGGLE <Component>
    • To translate a text component to the currently selected translation language choose Translate (see Tools : Options : Language for interface and collection translation options).
      Syntax: TRANSLATE <Component>
  • SuperMemo
    • To switch SuperMemo to a selected difficulty level use Level.
    • To set SuperMemo in one of its access modes (Read-Only, Learn-Only or Full Access), use Mode.
    • To show or hide the element navigation toolbar of the element window, use Navigation.
    • To show or hide the status bar use Status.
      Syntax: STATUS ON|OFF
    • To open the Question of the Day dialog box use Tips.
      Syntax: TIPS
  • Tests
    • To start a Drag&Match exercise for multiple labels and multiple images use DragMatch (multiple).
      Syntax: DRAGMATCH [<Label List>] [<Image list>]
      For example: DRAGMATCH [1,3,4,5] [6,7,8,9]
    • To start a Drag&Match exercise single image component with specified hit areas and multiple labels use DragMatch (single).
      Syntax: DRAGMATCH DRAGMATCH <Component> [<Label List>] [<Rectangle List>]
      For example: DRAGMATCH 1 [1,2] [(100,100,30,20),(150,200,50,20)]
      Hints: Use Image : Edit hit-area on the image pop-up menu to determine the positions of rectangles without complex coordinate calculations. Remember about the space between square brackets. See example
    • To determine if labels erase background of the image on which they are dropped in Drag&Match exercises, use DragTextMode.
    • To design Point&Click exercises use HitTest. Use an image that displays the hit area as the first argument, and a list of points that specify the correct hit area.
      Syntax: HITTEST <Component> [<list of points: (x1,y1)(x2,y2), etc.>]
      For example: HITTEST 1 [(10,10),(100,10),(100,100),(10,100)]
      Use Image : Edit hit-area on the image pop-up menu to determine the position of the hit area without worrying about coordinates. The hit area may include no more than five points. See example
    • To suspend the execution of a script until a grade is provided (e.g. in Drag&Match exercises or Point&Click exercises) use WaitGrade.
      Syntax: WAITGRADE
  • To insert a comment into the script, put it in a separate line and precede it with a semicolon.
    Syntax: ;<Comment>