Code Templates¶
Magician allows you to use and define code templates. Code templates are short pieces of syntactically correct Magik code, which can save you time by providing a framework for writing new code and can reduce bugs caused by typographical errors.
Using Code Templates¶
Magician comes with a set of ready-to-use code templates. To use an existing template, press Ctrl + J in the Magik prompt window or the Magician Editor window. The list of available code templates will appear.
You can type the first letter(s) of a template name to scroll down the list.
Double-click on the desired method. The code template for that method will be inserted at the current cursor location. The cursor will move to the location where you need to enter additional text.
Define Code Templates¶
To define new code templates, select Tools | Editor Options | desired_language from the Smallworld Magician 2000 menu bar. The Editor Options window appears. Click on the Code templates tab, as shown below:
This window allows you to add, edit (replace) or delete a code template.
To add a new code template, enter a new template name in the Name field and enter a short description of the template in the Description field. Then enter the Magik code that you want to store in the template in the Code template window.
To include the new template to the list of existing templates, verify that the Hotkey field is set to Ctrl + J. This should be the default.
Click on the Add button to add the template to the list of existing templates.
Press OK to save your changes and exit the Editor Options dialog box.

