I'm getting an error when I compile this program, it says Field Ident
required, what does that mean? and can someone help me fix them, thanks
Please help.
Program Assign4;
uses CRT;
Type bookin=RECORD
title:string[30];
AuthorLastName:string[15];
AuthorFirstName:string[15];
Publisher:string[25];
ISBN:string[13];
end;
type
ptr = ^stack;
stack = Record
End;
bookfiletype=FILE of bookin;
bookptr=^booknode;
booknode=RECORD
bookinv:bookin;
next:bookptr;
end;
var
bookfile:bookfiletype;
head:ptr; {always points to first node of list (or NIL)}
ct, n:Integer;
book:bookin;
{ Procedure Border
}
Procedure border{Draws the border for the menu or whenever required};
var
tempvar:integer; {using tempvar as a
counter}
begin
Begin
clrscr
end;
textcolor(yellow); {sets text colour to
yellow}
for tempvar:= 19 to 68 do
begin
gotoxy(tempvar,8);
write('')
end;
for tempvar:=9 to 17 do
begin
gotoxy(18,tempvar); {Puts cursor at specific point on screen
anywhere
from 2 - 24 on the Y Axis}
write('o')
end;
for tempvar:=9 to 17 do
begin
gotoxy(69,tempvar);
write('o')
end;
for tempvar:=19 to 68 do
begin
gotoxy(tempvar,18); {same as previous gotoxy, instead now on X
Axis}
write('')
end;
gotoxy(18,8);
write('');
gotoxy(69,8);
write('?');
gotoxy(69,18);
write('?');
gotoxy(18,18);
write('')
end;
Procedure SortList(head:ptr);
{Inserts single node in sorted position in ascending order}
VAR p, q:ptr;
Begin
NEW(q); {make new node}
q^.dat := bookinv; <--- get error here
q^.next := NIL; {last node always points to NIL}
If head <> NIL then {the list already exists}
Begin
If q^.dat < head^.dat then {new head}
Begin
q^.nxt := head;
head := q
End
Else
Begin {insert node or add new last node}
p := head;
While (q^.dat >= p^.nxt^.dat) AND (p^.nxt <> NIL)
Do p := p^.nxt;
q^.nxt := p^.nxt;
p^.nxt := q;
End; {nested if}
End
Else head := q; {because head = NIL at beginning}
End;
Procedure ShowList(head:ptr);
Var booknode:ptr;
Begin
booknode := head;
While booknode <> NIL Do
Begin
Write(booknode^.book.authorfirstname);
p := p^.nxt;
End;
Writeln;
End;
Procedure DeleteList(head:ptr); (***********BETTER***********)
VAR p:ptr;
Begin
While head <> NIL Do
Begin
p := head^.nxt;
Dispose(head);
head := p;
End;
End;
{ Procedure Record Add
}
{Procedure called by addrec to add records to file}
procedure recad;
var
response:char;
begin{begin recad procedure}
readln; {Used to clear keyboard
buffer}
repeat
clrscr;
seek(bookfile,filesize(bookfile)); {Locates end of
file}
write('Please enter book title: ');
readln(book.title);
write('Please enter Author''s Last name: ');
readln(book.authorlastname);
write('Please enter Author''s First name: ');
readln(book.authorfirstname);
write('Please enter Publisher: ');
readln(book.publisher);
write('Please enter ISBN: ');
readln(book.ISBN);
head := NIL; {to start list}
Begin
SortList(head);
End;
ShowList(head);
DeleteList(head);
{ write(head^.bookfile,book); {Writes all
entries to file}
write('Add another record (Y/N)?');
readln(response);
until (response='N') or (response='n') {Waits for correct
response
to continue}
end;{end procedure recad}
{ Procedure Addrec
}
{Gets into to add to output file}
procedure addrec;
var
infile:string;
titlein:string;
errorcode:integer;
response:char;
begin{begin addrec}
readln;
clrscr; {clears
screen}
border; {Calls procedure border to draw
border}
gotoxy(20,13);
writeln('Please enter desired file name');
gotoxy(20,14);
write('(eg:FILENAME.DAT): ');
read(infile);
assign(bookfile,infile); {assigns infile var to bookfile
name}
{$I-} {turns off file
checking}
reset(bookfile); {opens files to be
read}
Errorcode:=IORESULT; {sets error
code}
{$I+} {turns on file
checking}
if errorcode = 0 then {Checks if error code is
ok}
begin
recad {Calls procedure
recad}
end
else
begin
rewrite(bookfile); {Creates and opens new
file}
recad
end
end;
{ Procedure Listin
}
{Procedure listin, Lists all records in specified file}
procedure listin;
var
infile:string;
page:integer;
errorcode:integer;
x,y:integer;
remain:integer;
begin {begin listin}
clrscr;
readln;
border;
gotoxy(20,10);
writeln('Please enter file name to view ');
gotoxy(20,11);
write('contents (eg: FILESNAME.DAT): ');
readln(infile);
assign(bookfile,infile);
textcolor(white);
clrscr;
{$I-}
reset(bookfile);
errorcode:=IORESULT;
{$I+}
if errorcode=2 then
begin
clrscr;
writeln('File ',infile,' doesn''t exist');
end
else
begin
page:=0;
x:=1;
y:=1;
remain:=filesize(bookfile);
while not EOF( bookfile ) do
with book do
begin
if page = 4 then {Sets counter to
count up to 4
to display 4 record
on screen at 1
time}
begin
page:=0;
remain:=remain-4; {sets counter to
remain
to subtract 4 from
remaining records in
file}
textcolor(yellow);
write('Press ENTER to view next ');
textcolor(lightcyan);
write(remain);
textcolor(yellow);
write(' records.');
readln;
clrscr
end
else
begin
page:=page+1;
read(bookfile,book);
textcolor(white);
write(' Title: ');
writeln(title);
write(' Author''s Last Name: ');
writeln(authorlastname);
write('Author''s First Name: ');
writeln(authorfirstname);
write(' Publisher: ');
writeln(publisher);
write(' ISBN: ');
writeln(ISBN);
writeln
end
end
end;
gotoxy(24,25);
write('Press ENTER to return to main menu');
readln
end; {end listin}
{ Procedure Menu
}
{Draws menu for user, and waits for input}
procedure menu;
var
option:char;
response:char;
begin {begin menu}
repeat
clrscr;
border;
textbackground(red); {sets background color to red}
textcolor(white); {sets text color to white}
writeln;
gotoxy(19,9);
write(' '); {empty
line
used to fill text
color}
gotoxy(19,10);
write(' A');
writeln(' Add a new book
...