HiSoft Pascal Primer cover: a square, a triangle and a circle drawn and filled by a HiSoft Pascal program on the Tatung Einstein
← Back to Courses
module
4

Compiling And Running

Introduction

In the Turbo course, R compiled your program and ran it, and a mistake dropped you back into the editor with the cursor on it. HiSoft Pascal does neither. You leave XBAS, compile from the 0: prompt, run the result yourself - and when there is a mistake, it tells you where, by line number, and you go back to XBAS to fix it.

HPEIN

With FIRST.ASC saved from S3, leave XBAS with DOS and type:

HPEIN FIRST

The name is given without .ASC. HiSoft Pascal signs on and lists your program as it compiles it:

Hisoft Pascal for the Tatung Einstein
Version of 24 October 1984
Copyright Hisoft 1984.
All rights reserved.
0E41     10 PROGRAM FIRST;
0E41     20 (* THREE NUMBERS *)
0E41     30 VAR A:ARRAY[1..3] OF INTEGER
;
0E42     40 BEGIN
0E6B     50 A[1]:=4; A[2]:=5;
0EB1     60 A[3]:=A[1]*A[2];
0F12     70 WRITELN(A[3])
0F3E     80 END.
End Address: 0F43
0:

Each line starts with the memory address its code begins at, then your XBAS line number, then the line. A line too wide for the screen runs on to the next row, as line 30 does here; that is only the display. End Address is where the program's code ends.

No news is good news: when there are no mistakes, it says no more than that. It has written FIRST.COM to the disc.

Running It

Type the name:

FIRST

and it prints 20 and comes back to 0:. That is a complete program that runs on its own - what the Turbo course reached in S37, you have from the start. It is small, too: a four-line program comes to 3,584 bytes, where Turbo's Hello was 8,064.

Compiling Again

Compile FIRST a second time and HiSoft Pascal stops at once:

File exists - Delete?

FIRST.COM is already there. Press Y to compile over it. Any other key goes back to 0: and leaves the old FIRST.COM alone.

Since you will compile over the last version nearly every time, you can answer in advance: put ;Y after the name.

HPEIN FIRST;Y

When It Will Not Compile

Change line 70 in XBAS to WRITELIN(A[3]), save, and compile. The listing stops at the line:

0F12     70 WRITELIN(A[3])
 *ERROR*           ^ 3

The ^ points just after the part it could not accept, and 3 is the error's number. The manual's Appendix 1 lists them all; 3 is "Undeclared identifier" - HiSoft Pascal has never heard of WRITELIN.

Then it waits for a key. Press E to go straight back to 0:, or any other key to carry on and find the next mistake. A misspelling like this one usually sets off several more errors after the first, all from the same cause, so E is generally the right answer.

A compile that finds any error writes no .COM - and deletes the old one. After a failed compile, FIRST answers No File.

Then the round trip: XBAS, LOAD "FIRST.ASC", retype line 70, SAVE "FIRST.ASC", DOS, HPEIN FIRST;Y. It is four steps where Turbo had one, and it is the rhythm of working with HiSoft Pascal.

Options

Letters after a semicolon change how HPEIN works. Three besides Y:

OptionDoes
;BThe file has no line numbers - for a file written some other way than XBAS
;TIncludes FRAC, SIN, COS and the other maths functions (S6)
;RLeaves out real numbers entirely: a four-line program comes to 1,920 bytes

Several go together, separated by commas: HPEIN FIRST;Y,T. And a different name first makes the .COM under that name: HPEIN TWENTY FIRST compiles FIRST.ASC to TWENTY.COM.

The Code

The whole round, from S3's saved FIRST.ASC:

HPEIN FIRST
FIRST

Starting from

FIRST.ASC saved as in S3, the 0: prompt, no FIRST.COM on the disc yet.

What you should see

The sign-on, the eight-line listing and End Address: 0F43, then 0:. FIRST prints:

20

Change One Thing

Make each change in XBAS, save, and compile with ;Y:

  • Take the full stop off END. in line 80. What does the compiler say when it reaches the end of the file?
  • Change line 70 to WRITELIN(A[3]). Which number does it give, and what happens when you press E? Is FIRST.COM still there?
  • Put the name back, and change line 60 to A[4]:=A[1]*A[2];. The array only goes up to 3. Does it compile? What happens when you run it?

Exercises

4.1 Compile and run the program you saved as NAME.ASC in Exercise 3.1.

4.2 Compile FIRST.ASC so that the program is called TWENTY.COM, and run it by its new name.

Worked solutions are in Appendix II.

When It Goes Wrong

SymptomCause
No Source File: FIRST .ASCThe file is not on the disc - it was never saved, or saved under another name.
File exists - Delete?The .COM is there from last time. Y, or compile with ;Y.
The compile stops with *ERROR* and nothing happensIt is waiting for a key: E to stop, anything else to go on.
No more textThe program ran out before END. - usually a missing full stop.
The old program runs, not the new oneYou answered anything but Y to File exists - Delete?, or the change was never saved.
No File when you run itThe compile failed, and a failed compile deletes the .COM.

Summary

HPEIN NAME compiles NAME.ASC to NAME.COM, listing every line with its XBAS number; NAME runs it. Recompiling asks File exists - Delete? - Y, or add ;Y. A mistake shows *ERROR*, a ^ and a number, and waits: E stops. A failed compile leaves no .COM. Fix the line in XBAS, save, compile again.

Next

S5, When A Program Stops - the run-time errors, and a difference in how a runaway program is stopped that changes how fast your programs run.

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.