Mouse In A Hole, the platform game the course builds in Xtal BASIC 4.2, running on the Tatung Einstein: the mouse mid-jump between platforms, two cats and the cheese
← Back to Courses
module
3

Talking To BASIC

Introduction

A computer from 1984 will not guess what you meant. BASIC waits for you to type a line, and when you press ENTER it does exactly what that line says - which is wonderful when the line is right and baffling for a minute when it is not.

It always tells you which. This section gets you to the point where you can read its replies, type the characters that are not where your keyboard says they are, and get out cleanly.

Starting BASIC

Boot the disc, and at 0: type XBAS and press ENTER, as in S2. BASIC signs on and says Ready, with the cursor blinking below it.

If you have a real Einstein, the same: your System Master, XBAS, ENTER.

Typing A Line

Nothing happens until you press ENTER. You can type as much as you like, and until ENTER the line is just characters on the screen. Press DELETE and the last character is rubbed out; type again and it is replaced. When the line reads as you want it, ENTER hands it to BASIC.

In MAME, DELETE is Backspace and ENTER is Return.

BASIC starts with capitals on. Everything you type comes out in capitals, and that is fine - it does not care whether you type PRINT or print, and you will see later that it turns its own words into capitals whatever you typed. If you want small letters, in a message say, press CAPS LOCK and they come back; press it again for capitals.

What BASIC Says Back

Type this and press ENTER:

PRINT "HELLO"

Two things come back, on two lines:

HELLO
Ready

The first is what you asked for. The second is BASIC saying it has done it and is waiting for the next line. Ready follows every line BASIC accepts, and you stop noticing it within the hour.

Now this:

PRINX "HELLO"
Syntax Error
Ready

PRINX is not a word BASIC knows, so it does not do anything, says so, and - notice - still says Ready. An error costs you nothing but the line. You will see Syntax Error a great deal, and it always means the same thing: BASIC could not make sense of what you typed. A misspelt word, a bracket too few, a key that gave a character you did not mean. Look at the line, find it, type it again.

There are other messages for other troubles, and they are just as plain. Ask for something impossible:

PRINT 1/0
Division Error
Ready

The line was perfectly good BASIC; it asked for a sum that has no answer. Different problem, different message, and Ready again afterwards.

Words And Sums

PRINT is the word for "show me". What it shows depends on what follows.

Text in double quotes is shown exactly as it is - PRINT "HELLO" gives HELLO. A sum without quotes is worked out first and the answer is shown:

PRINT 7-2
 5

with a space in front of it, which is how BASIC shows a number. And the same thing in quotes is text again, and is not worked out:

PRINT "7-2"
7-2

That is the whole difference between quotes and no quotes, and it runs through everything that follows. Inside quotes, BASIC copies. Outside them, it calculates.

Two Keyboards

While the MAME window is in front, your keyboard is the Einstein's, and MAME lays the Einstein's keys over yours by position. The letters, digits and most punctuation are where you expect. A handful are not, and this section uses two of them already.

To typeOn the EinsteinIn MAME
"SHIFT and 2SHIFT and 2, whatever your 2 says
- (minus)SHIFT and the = keySHIFT and =
( and )SHIFT and 8, SHIFT and 9SHIFT 8 and SHIFT 9 - one key to the left of where a modern keyboard has them
: and *the key marked : *, plain and shiftedthe ' key, plain and shifted
; and +the key marked ; +, plain and shiftedthe ; key, plain and shifted
=the = key=
@SHIFT and 0SHIFT and 0
^the up arrowthe up arrow
_the key marked -the - key
[ and ]the left and right arrowsthe left and right arrows

The one that catches everybody is minus. The key with - on it gives an underscore, and PRINT 7_2 prints 7 and then stops with Syntax Error at the character it cannot read. Minus is SHIFT and =.

On the Einstein's screen, three of these look different from the way this course prints them: [ is drawn as a left arrow, ] as a right arrow and ^ as an up arrow - the arrows on the keys that type them. They are the same characters; only the drawing differs.

At a real Einstein, the middle column is all you need. Appendix IV has the whole keyboard in one place, for both.

The Code

PRINT "HELLO"
PRINT 7-2
PRINT "7-2"
PRINX "HELLO"

Four separate lines, each followed by ENTER.

Starting from

A fresh boot, with BASIC just started.

What you should see

PRINT "HELLO"
HELLO
Ready
PRINT 7-2
 5
Ready
PRINT "7-2"
7-2
Ready
PRINX "HELLO"
Syntax Error
Ready

The four lines and BASIC's replies

Change One Thing

  • Press CAPS LOCK and type print "hello" in small letters. Which parts come out in small letters, and which does BASIC not mind about?
  • Type PRINT "HELLO and leave the closing quote off. Does BASIC complain?
  • Type PRINT on its own and press ENTER. What do you get, and is it an error?

Exercises

3.1 Print your own name.

3.2 Print 2+2 worked out, and then print it as text, on two lines.

3.3 Print TWOWORDS from two separate quoted words on one PRINT line, using a semicolon between them. Then find out what PRINT 10/4 gives.

Worked solutions are in Appendix II.

Leaving

BASIC has a word for going back to the disc operating system:

DOS

The screen clears and 0: comes back. Typing XBAS there starts BASIC again from scratch - and anything you had typed in is gone. S6 shows how to keep it. Until then, DOS is how you finish, and closing the MAME window, or switching a real Einstein off, does the same.

When It Goes Wrong

SymptomCause
Syntax ErrorBASIC could not read the line. A misspelt word, a bracket too few, or the wrong key - see the next two rows.
PRINT 7_2 prints 7 and then Syntax ErrorThe key marked - types an underscore. Minus is SHIFT and =.
Your " key gives some other characterYour keyboard's legends do not apply. " is SHIFT and 2.
Division ErrorYou asked for a number divided by zero. The line was fine; the sum was not.
Everything is in capitalsCAPS LOCK is on, which is how BASIC starts. Press it if you want small letters in a message.

Summary

Type a line, press ENTER, read the reply. Ready means done; Syntax Error means BASIC could not read the line, and costs nothing. PRINT shows text in quotes as it is and works out anything outside them. Minus is SHIFT and =. DOS leaves.

Next

S4, Your First Program - numbering lines so the machine keeps them, and running them in order.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.