heres a new prog, with better stuff than the last i gave you-nimrod
program displaymag;
uses crt;
var magnam :string;
exit :boolean;
option :integer;
name :array[1..20] of string;
price :array[1..20] of real;
mag :text;
key :char;
pointer :integer;
nomags :integer;
procedure readfile;
begin
assign(mag,'mfile.dat');
reset(mag);
pointer:=1;
readln(mag,name[pointer]);
while not eof(mag) do
begin
readln(mag,price[pointer]);
pointer:=pointer+1;
readln(mag,name[pointer]);
end;
nomags:=pointer-1;
end;
procedure display;
begin
writeln('Please enter the name of the magazine');
readln(magnam);
for pointer:=1 to nomags do
begin
if name[pointer]=magnam then
begin
writeln(name[pointer],' costs ',price[pointer]:6:2);
key:=readkey;
end;
end;
end;
procedure displayall;
begin
clrscr;
pointer:=1;
for pointer:=1 to nomags do
begin
writeln('name ',name[pointer],' price ',price[pointer]:6:2);
end;
key:=readkey;
end;
procedure menu;
begin
writeln('`1` Display All Magazines');
writeln('`2` Display Selected Magazine');
writeln('`3` Exit');
readln(option);
case option of
1: begin
displayall;
end;
2: begin
display;
end;
3: begin
exit:=true;
end;
end;
clrscr;
end;
{main program}
begin
clrscr;
readfile;
repeat
menu;
until exit;
end.
|