Topic: APLX Help : Help on APL language : APL Primitives : ∇ Line editor
[ Previous | Next| Contents | Index | APL Home ]

www.microapl.co.uk

Line Editor


opens or closes function definition mode, a simple line editor (or 'del' editor) for editing functions, operators and classes. Although largely obsolete because APLX offers powerful on-screen editing facilities via the Edit menu or )EDIT, it is retained for compatibility with older systems. It is also sometimes useful for creating very small functions.

Editing functions and Operators

(For brevity, we use the word 'function' in this section to denote either user-defined functions or user-defined operators).

followed by a name or function header (for a function which does not already exist in the workspace) opens definition mode. If the function already exists, you should follow it with just the name, not the full header.

The editor prompts you with the next line number, in square brackets. (Note that the function header is line 0.)

To enter a line for the line number which is being shown, just type the line. When you press Enter, the line will be fixed and you will be prompted with the next line number.

By entering line numbers and other characters in square brackets, you can control the editor, as in the following examples:

∇NAME[⎕]  Enter editor, open function NAME, list whole function 
[⎕]       List function (once you have opened it)
[⎕4]      List from line 4 onwards
[3]       Overwrite line 3
[3] ...   Overwrite line 3 immediately
[5.1]     Insert new line after line 5
[∆2]      Delete line 2 from the function
[4⎕6]     Place cursor at line 4, character position 6
[4⎕0]     Place cursor at end of line 4
[0⎕0]     Place cursor at end of the function header

To insert a line, use a fractional line number between the line numbers of the lines on either side of the insertion point. For example, [3.1] will insert a line between existing lines 3 and 4 (and you will be prompted with [3.2] as the next line).

Note that you can edit the line number itself. This has the effect of copying the line to the new position, either inserting a new line, or overwriting an existing line.

When you have finished editing, type another character to end the edit session. Lines will be automatically re-numbered in sequence 1 to N, to allow for any insertions or deletions.

Defining or editing a class using the line editor

The line editor can also be used to create or edit a class, in much the same way as it is used to edit a function or operator. To define a new class, open the line editor by entering a line which begins with the del () character, is followed by the header line of the class (optionally including a parent class name and localized names, as per the canonical representation), and which ends with a left curly brace. APLX will open the class definition, and prompt you with the name of the class in curly braces as a reminder that you are in class-edit mode. For example, we can create a new class Sphere which inherits from Point:

      ∇Sphere : Point {
{Sphere}:

You can then define properties by entering lines in the same format as the canonical representation of a class. After each line, APLX prompts again with the class name enclosed in curly braces:

      Radius←0
{Sphere}:

You can also enter methods by using the del editor in the normal way (you will be prompted with the line number until you finish editing the method, then return to class-definition mode and again be prompted with the class name):

      ∇R←Volume
[1]   R←1.333333333333×(○1)×Radius*3
[2]   
{Sphere}:

Finally, exit from class-definition mode by entering a single right curly brace:

      }

The canonical representation of the class defined in this way would then be as follows:

      ⎕CR 'Sphere'
Sphere : Point {
Radius←0

∇R←Volume
R←1.333333333333×(○1)×Radius*3
∇
}



Topic: APLX Help : Help on APL language : APL Primitives : ∇ Line editor
[ Previous | Next| Contents | Index | APL Home ]