home *** CD-ROM | disk | FTP | other *** search
- SCRIPT Students; (* This is a simple script to *)
- VAR (* demonstrate STRING and INTEGER *)
- Age : ARRAY [0..19] OF INTEGER; (* arrays. It asks for the names *)
- Name : ARRAY [0..19] OF STRING; (* of up to 20 pupils and their *)
- Count : INTEGER; (* ages, and then displays them. *)
- AgeStr : STRING[3];
- Useful : INTEGER;
- Round : INTEGER; (* V.1.10 for Deputy 3.00 and later *)
- BEGIN
- ClrScr;
- WrLn('\nType in the names/ages (ENTER a blank to end)');
- WrLn('-----------------------------------------------');
- Count:=0;
- REPEAT
- WrLn;
- Write('Name of Person No.'); Write(Count+1); Write(': ');
- Read(Name[Count]);
- IF Name[Count]<>'' THEN
- REPEAT
- Write(' Age of Person No.'); Write(Count+1); Write(': ');
- Read(AgeStr);
- StrToInt(AgeStr,Useful);
- Age[Count]:=Useful;
- IF (Age[Count]<1) OR (Age[Count]>30) THEN
- WrLn('Sorry Invalid Age, try again !');
- WrLn;
- END;
- UNTIL (Age[Count]>0) AND (Age[Count]<31);
- END;
- INC(Count);
- UNTIL (Name[Count-1]='') OR (Count=19);
- DEC(Count,2);
- ClrScr;
- WrLn('\nHere are the details of your names:');
- WrLn('-----------------------------------\n');
- FOR Round:=0 TO Count DO
- Write('Student No.');
- Write(Round+1);
- Write(': ');
- Write(Name[Round]);
- GotoXY(25,WhereY);
- Write('Age: ');
- WrLn(Age[Round]);
- END;
- END Students.