
In the Turbo course, the editor was part of Turbo Pascal: E, type, CTRL-K CTRL-D, S. HiSoft Pascal has no editor at all. Its manual's answer is to use the one every Einstein already has - XBAS, the Einstein's BASIC. You type your Pascal into it as if it were a BASIC program, a numbered line at a time, and save it as a text file for the compiler to read.
Start XBAS from the 0: prompt, and type a program with a line number at the front of each line:
10 PROGRAM FIRST;
20 BEGIN
30 WRITELN(20)
40 END.
XBAS does not try to run any of it. A line that starts with a number is simply stored, in number order. LIST shows what is stored:
10 PROGRAM FIRST;
20 BEGIN
30 WRITELN(20)
40 END.
The numbers are only for XBAS, to keep the lines in order and to let you change them. The compiler skips over them (S4). Count in tens, as BASIC programmers do, so that there is room to put a line in between later.
One Turbo habit does not survive: indenting. XBAS keeps only one space after the line number, however many you type, so every line starts at the left. The listings in this primer are written that way.
If typing the numbers is tedious, type AUTO first. XBAS then puts 10, 20, 30... in front of each line for you. It does not stop by itself, and ESC does not stop it: when you are done, press ENTER on the empty number it offers. XBAS answers Branch Error and Ready - take no notice, your lines are kept.
There is no cursor to move round the program as there was in Turbo's editor. You change a program a whole line at a time, by its number:
25 goes after 20.RENUM renumbers the whole program in tens again, when the gaps run out.LIST shows the program as it is now.XBAS starts with CAPS LOCK on, so everything you type comes out in capitals - and Pascal's own words have to be in capitals for HiSoft Pascal: BEGIN, not begin. Even if you press CAPS LOCK, XBAS turns every small letter into a capital when it stores the line - including the ones inside Pascal's quotes. (XBAS spares only text in double quotes, BASIC's kind of string, which Pascal does not use.) So all your programs will look like the ones in this primer, capitals throughout, and every message they print will be in capitals. A small letter in a message has to be written as a character code: CHR(97) is a.
Two things from the Turbo course need a different key here.
[ and ] are typed with the LEFT and RIGHT arrow keys, as they were in Turbo. On the screen they show as arrows, ← and →, because that is how the Einstein draws those two characters. In the file they are brackets, and the compiler reads them as brackets.
{ and } cannot be used for comments. XBAS takes them for BASIC words: type { NOTE } and it stores OR NOTE >, which the compiler then refuses. Write comments with (* and *) instead - they pass through untouched.
XBAS reads those braces as BASIC even inside quotes - and three more characters with them. Wherever you type them, it stores something else:
| You type | XBAS stores |
|---|---|
? | PRINT |
{ | OR |
| | XOR |
} | > |
~ | / |
The one you will miss is the question mark. WRITE('READY? ') comes out of XBAS as WRITE('READYPRINT '). When a message needs one, write it as a character code - CHR(63) is ?:
WRITELN('READY',CHR(63))
prints READY?. Every other character on the keyboard goes through as typed.
The compiler cannot see what is in XBAS's memory. It reads a file from the disc, and the file's name must end .ASC:
SAVE "FIRST.ASC"
Save after every change, before you compile - whatever you changed after the last SAVE is not in the file, and the compiler never sees it. Saving over the old file is fine: XBAS replaces it without asking.
To start a fresh program, NEW empties XBAS's memory. To carry on with a program you saved, LOAD "FIRST.ASC" brings it back. DOS leaves XBAS for the 0: prompt - with the program in its memory gone, so save first.
A program with an array, to try the arrow keys, and a comment. Type it into XBAS:
10 PROGRAM FIRST;
20 (* THREE NUMBERS *)
30 VAR A:ARRAY[1..3] OF INTEGER;
40 BEGIN
50 A[1]:=4; A[2]:=5;
60 A[3]:=A[1]*A[2];
70 WRITELN(A[3])
80 END.
Then:
LIST
SAVE "FIRST.ASC"
NEW
LIST
LOAD "FIRST.ASC"
LIST
Starting from
The primer's disc, XBAS typed at 0:.
What you should see
The first LIST shows the eight lines, numbers moved to the right, and every [ and ] drawn as an arrow:
10 PROGRAM FIRST;
20 (* THREE NUMBERS *)
30 VAR A:ARRAY←1..3→ OF INTEGER;
40 BEGIN
50 A←1→:=4; A←2→:=5;
60 A←3→:=A←1→*A←2→;
70 WRITELN(A←3→)
80 END.
SAVE answers Ready. After NEW, LIST shows nothing. After LOAD, the same eight lines are back. S4 compiles it.
Make each change after the LOAD, then LIST:
70 WRITELN(A[1],A[2],A[3]). What happens to the old line 70?20 on its own. Where has the comment gone?55 A[3]:=0;. Where does it appear in the listing?Then think ahead: if you compiled FIRST.ASC now, without saving again, which version of line 70 would the compiler see?
3.1 Use AUTO to type a four-line program that writes your name, and save it as NAME.ASC.
3.2 Load FIRST.ASC, put a new line between every pair of lines (any comment will do), then RENUM it and LIST it. What numbers do the lines have now?
Worked solutions are in Appendix II.
| Symptom | Cause |
|---|---|
A comment comes back as OR ... > | It was typed with { }. Use (* *). |
PRINT appears in a message | A ? was typed. Use CHR(63). |
| A line has a number like 601 | Its Pascal started with a digit, which XBAS read as part of the line number. Put (**) in front of it (S10). |
Branch Error after typing a lone number | There is no line with that number to delete - or you pressed ENTER on an empty AUTO number, which is how you leave AUTO. |
| The compiled program does not have your last change | It was made after the last SAVE. Save, then compile. |
The program is gone after DOS | Leaving XBAS forgets the program. XBAS, then LOAD "NAME.ASC". |
Type Pascal into XBAS as numbered lines, in capitals, with the arrow keys for [ and ], (* *) for comments and CHR(63) for a question mark. Change a line by retyping its number; delete it by typing the number alone; RENUM tidies the numbers. SAVE "NAME.ASC" writes the file the compiler reads - save after every change. NEW empties, LOAD brings back, DOS leaves.
S4, Compiling And Running - handing FIRST.ASC to HiSoft Pascal.