
Everything you type into Turbo's editor lives in the machine's memory until you save it, and memory forgets the moment the Einstein is switched off. The disc does not. This section is about the traffic between the two - and about the other thing Turbo can put on a disc, which is a finished program that runs on its own.
You met S in S4:
Saving A:HELLO.PAS
Do it often. It takes a second, and it is the difference between losing a minute's work and losing an evening's.
The first time you save a new program, the disc gains one file. Every time after that, it keeps two. Save HELLO a second time and then look with D:
HELLO BAK : HELLO PAS
HELLO.PAS is what you just saved. HELLO.BAK is the version it replaced - Turbo renames the old file rather than destroying it, so that if you have just saved something you regret, the one before is still there.
Files cost disc space, and not by the byte. The four-line HELLO program is well under a hundred bytes, but each file takes at least 2k of the disc: saving it, and then saving it again, takes Bytes Remaining from 80k to 76k. With 80k to start with, there is room for plenty of work, but .BAK files add up. The end of this section shows how to clear them away.
W with the name of a program that is on the disc loads it:
Loading A:HELLO.PAS
and no New File - that is how you can tell it found it. E then shows it in the editor, just as you left it.
If you have changed the program you are working on and not saved it, W stops to ask first:
Workfile A:HELLO.PAS not saved. Save (Y/N)?
Y saves it and then asks for the new name; N throws your changes away. Q asks the same question, for the same reason. Read it every time.
Turbo can list the disc but not delete from it. The disc operating system can. Quit Turbo with Q, and at the 0: prompt type ERA, a space, and the file's full name:
0:ERA HELLO.BAK
0: HELLO .BAK?
It asks before it acts. Press Y:
0: HELLO .BAK?Y Erased
Any other key leaves the file alone. If there is no such file it says No File. Type TURBO to go back.
ERA does not care whether it is erasing a .BAK or the only copy of a week's work. Give it the name you mean.
When you press R, Turbo compiles your program into memory and runs it there, and the machine code vanishes when you leave Turbo. Turbo can also write the machine code to the disc, as a program the disc operating system can run by itself - the same kind of file as TURBO.COM.
Press O, for compiler Options:
compile -> Memory
Com-file
cHn-file
Find run-time error Quit
The arrow says where compiled programs go. Press C and it moves to Com-file, and two lines about addresses appear, which you can ignore. Press Q to go back to the main menu, and press C, for Compile:
Compiling --> A:HELLO.COM
4 lines
Code: 57 bytes (1FC9-2002)
Free: 51379 bytes (2003-E8B6)
Data: 131 bytes (E8B7-E93A)
The arrow on the first line says where it went: a new file on the disc, HELLO.COM. Quit Turbo, and at the 0: prompt just type its name:
0:HELLO
Hello, Einstein
0:
No Turbo, no menu - your program, run as the machine runs any other.
It is bigger than you might expect. HELLO.COM is 8,064 bytes, for 57 bytes of your own code. Borland's manual explains why: a .COM file carries with it the part of Turbo that every Pascal program needs in order to run - Turbo's "run-time library" - because Turbo will not be there to provide it. On the disc, HELLO.COM and VERSE.COM each cost 8k.
Two things to know about Com-file mode:
TURBO, the Options menu says Memory again. To go back sooner, O, M, Q.R runs the .COM file rather than compiling into memory, and Turbo then has to load its own messages and your work file again from the disc. For the everyday edit-and-run of writing a program, stay in Memory.MAME writes to the course disc because it is an .mfi. If you ever run Turbo from a .dsk image, the first save goes like this:
Saving A:HELLO.PAS
Bad Data 0:
Try Again(Y/N)?
Do not answer N. It does not return you to Turbo: it drops you straight out to the 0: prompt, and whatever you had typed is gone. There is no good answer from here; the lesson is to use the course disc.
This section's program is S4's exercise 4.2, the verse:
program Verse;
begin
Writeln('Roses are red,');
Writeln('Violets are blue,');
Writeln('Turbo is quick');
Writeln('And so are you.');
end.
Load it with W VERSE (or type it, and save it as VERSE), then O, C, Q, and C to compile it to VERSE.COM. Then Q, and at 0:, type VERSE.
Starting from
Turbo freshly started, Y; VERSE.PAS saved on the disc.
What you should see
After C: Compiling --> A:VERSE.COM, 7 lines, and Code: 141 bytes. At 0::
0:VERSE
Roses are red,
Violets are blue,
Turbo is quick
And so are you.
0:
D. What has appeared?Bytes Remaining before and after you compile VERSE.COM. How much of the disc did it take?.COM, and look at the Options menu. Where does the arrow point now?6.1 Make HELLO.COM from your S4 program, and run it from the 0: prompt.
6.2 Save your verse program as VERSE, restart the Einstein, and get it back into the editor.
6.3 Erase every .BAK file you have made, one at a time, and check with DIR that the programs themselves are still there.
Worked solutions are in Appendix II.
| Symptom | Cause |
|---|---|
W says New File for a program you saved | The name is not quite the one you saved it under. Check with D. |
Workfile ... not saved. Save (Y/N)? when you only wanted to load something | You have changes that are not on the disc. Y keeps them. |
Bad Data 0: and Try Again(Y/N)? when saving | You are running from a .dsk image, which MAME will not write to. N leaves Turbo and loses the text. Use the course disc, an .mfi. |
R runs the program but says nothing about compiling, then Loading A:TURBO.MSG | Com-file mode is still on. O, M, Q. |
ERA did not erase | You pressed something other than Y at its question. |
No File at 0: | No file of that name - the name or its type is wrong. |
| The disc is filling up | .BAK and .COM files. Each .COM is about 8k. Erase what you do not need. |
S saves, and the previous version becomes .BAK. W loads, and warns you first if your changes are not saved; so does Q. ERA at the 0: prompt erases a file, after asking. O, C, Q, C compiles your program into a .COM file that runs on its own from 0: - about 8k however small the program.
S7, Sums - numbers, and making Turbo do arithmetic.