home *** CD-ROM | disk | FTP | other *** search
- { PASCAL Program : pas-exam.spe
- Date written : 3-3-86
- Author : Ortolf
- Structogram saved on disk : Spe110
- Pascalsource saved on disk : Pas52
-
- * main program
- }
- program pasbsp1 (input, output);
- label 0909, 0918;
- const
- t1 = 'Program Name: pas-exam.spe.';
- t2 = 'Create file (1), display file (2)? ';
- var
- zchen : char;
- {
- * subroutine
- }
- procedure zweite;
- label 0484;
- const
- t3 = 'Display another record (y/n)? ';
- var
- eins : string (80);
- zchen : char;
- ein : text;
- a : integer;
- begin
- assign (ein, 'pasbsp1.dat');
- reset (ein);
- a := 1; { initiate condition }
- { conditioned loop
- while a = 1 loop }
- while a = 1 do
- begin
- { reading sucessful }
- if (eof(ein))
- then begin
- { EOF }
- goto 0484
- end else begin
- readln (ein, eins); { read record }
- writeln (eins); { display record }
- writeln (t3);
- readln (zchen);
- { another record? }
- if (zchen = 'y')
- then begin
- { yes }
- end else begin
- { no }
- a := 0;
- end
- end
- end;
- 0484:
- close (ein)
- end;
- {
- * subroutine
- }
- procedure pasbsp;
- label 0810;
- const
- t3 = 'How many record are to be written? ';
- var
- auss : string (80);
- zaehl : integer;
- anzahl : integer;
- aus : text;
- begin
- { case 1
- create file }
- assign (aus, 'pasbsp1.dat');
- rewrite (aus);
- writeln (t3); { input number of records }
- readln (anzahl);
- for zaehl := 1 to anzahl do
- { indexed loop }
- begin
- readln (auss); { input record }
- writeln (auss); { display record }
- writeln (aus, auss); { write record }
- end;
- 0810:
- close (aus);
- end;
- begin
- writeln (t1);
- { an unconditioned loop is
- following }
- 0909:
- begin
- writeln (t2);
- readln (zchen);
- { case }
- if (zchen = '1')
- then begin
- { case 1 }
- pasbsp { create file }
- end else
- if (zchen = '2')
- then begin
- { case 2 }
- zweite { display file }
- end else begin
- { else-case
- end }
- goto 0918
- end
- end;
- goto 0909;
- 0918:
- end.