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
7

Names

Introduction

Names in the Turbo course were forgiving: capitals or small letters, as long as you like. HiSoft Pascal has three rules of its own. Two of them XBAS takes care of for you. The third can cost you an evening.

Capitals

HiSoft Pascal's own words - PROGRAM, BEGIN, WRITELN, INTEGER - must be in capitals. A program typed in small letters is refused from its first word. And to HiSoft Pascal, Count, COUNT and count are three different names.

Neither matters while you use XBAS, because XBAS turns every small letter into a capital as it stores a line. Your programs will always be in capitals, and Count and count will always be the same name - as they were in Turbo.

Eight Characters

Only the first eight characters of a name count. TOTALSCORE1 and TOTALSCORE2 both begin TOTALSCO, so to HiSoft Pascal they are the same variable - and nothing tells you so. Long names are still allowed, and still worth using; just make them differ in the first eight characters: SCOREONE, SCORETWO.

Twice Over

The compiler does not check whether you have declared a name already. VAR X,X:INTEGER; compiles. A name declared a second time with a different type quietly becomes the second type, and the first you hear of it is an error where the program uses it the first way. It is the same trap as the eight characters: two names you meant to be different, treated as one.

The Code

10 PROGRAM NAMES;
20 VAR TOTALSCORE1,TOTALSCORE2:INTEGER;
30 BEGIN
40 TOTALSCORE1:=10;
50 TOTALSCORE2:=20;
60 WRITELN(TOTALSCORE1,TOTALSCORE2)
70 END.

Starting from

NAMES.ASC saved from XBAS; HPEIN NAMES.

What you should see

It compiles without a murmur, and prints:

20 20

Line 50 changed the one variable both names stand for.

Change One Thing

  • Change TOTALSCORE2 to SCORETWO everywhere it appears. What does it print now?
  • Put TOTALSCORE2 back, and add TOTALSCORE1:CHAR; to the end of line 20. Which lines does the compiler complain about, and why those?
  • Type line 60 again in small letters, with CAPS LOCK off. LIST it. What has XBAS done to it?

Exercises

7.1 A program keeps a player's HIGHSCORE and HIGHSCORETODAY. Will HiSoft Pascal keep them apart? Write a program to find out.

Worked solutions are in Appendix II.

When It Goes Wrong

SymptomCause
Two variables change togetherTheir names are the same in the first eight characters.
*ERROR* 10 where nothing looks wrongThe name was declared again, with another type.
A program from elsewhere is refused from the first wordIt is in small letters. Type it into XBAS, which makes it capitals.

Summary

HiSoft Pascal needs its words in capitals and tells names apart by their first eight characters only; XBAS makes everything capitals for you. The compiler does not notice a name declared twice. Keep names different in their first eight characters.

Next

S8, Text Without Strings - there is no string in HiSoft Pascal.

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.