
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.
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.
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.
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.
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.
TOTALSCORE2 to SCORETWO everywhere it appears. What does it print now?TOTALSCORE2 back, and add TOTALSCORE1:CHAR; to the end of line 20. Which lines does the compiler complain about, and why those?LIST it. What has XBAS done to it?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.
| Symptom | Cause |
|---|---|
| Two variables change together | Their names are the same in the first eight characters. |
*ERROR* 10 where nothing looks wrong | The name was declared again, with another type. |
| A program from elsewhere is refused from the first word | It is in small letters. Type it into XBAS, which makes it capitals. |
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.
S8, Text Without Strings - there is no string in HiSoft Pascal.