error msg when compiling program 
Author Message
 error msg when compiling program

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
...

read more »



Wed, 18 Jun 1902 08:00:00 GMT  
 error msg when compiling program

Quote:

> 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.

It means that the compiler expects to find a fiel ident at the place,
where the error occurs. Typically this is a result of a lapse (oops,
I forgot the name of this fiels) or a typo.

example:

suppose that you define the following type

type
 f_record=record
           fo:integer;
           foo:real
           fooo:string;
          end;

and then later in write

procedure read_f(var f:f_record);
begin
 writeln('Give me a fooo!');
 readln(f.foooo); <- You get this error message right here,
                     because f. must be followed by either
                     'fo', 'foo' or 'fooo'. These are the field
                     idents of the fields of a variable of type
                     'f_record'. Here obviously a typo occured.
end;

I used to often get this error message myself. The reason
was that my record definitions where a few hundred/thousand lines
further back in the source window. So I learned to write down
my record definitions on a piece of paper for easy reference.
Alternative solutions exist, e.g. you could keep your type
definitions in a separate file and have that open in a different
window within the IDE or do whatever works for you...

BTW: We mean it, when we ask you to only post the relevant part
of your code (here the type definitions and the errorneous
procedure). You may already have turned off more helpful replies
as your message is now hundreds of lines and some more knowledgeable
people didn't bother reading your message as they may pay per line.

--
Jyrki Lahtonen, Ph.D.
Department of Mathematics,
University of Turku,
FIN-20014 Turku, Finland

http://users.utu.fi/lahtonen



Wed, 18 Jun 1902 08:00:00 GMT  
 error msg when compiling program
I cannot see any declaration of "dat" and "next", as P and Q are a pointer
to an EMPTY Record (with no fields in it).

Quote:
> type
> ptr = ^stack;
> stack = Record          Record IS EMPTY!!!!!!
>         End;

Should P & Q not have been declared  as BookPtr?

Later you use a field called "nxt" from record pointed to by ptr. But again:
"nxt" has not been declare anywhere.
BookInv is not a variable inside the procedure SortList, but part of
BookPtr^ or BookNode.

Try to compile the program "by hand".
That is: make some drawing on paper with pointer going between items like
your pointers and the blocks containing the data.

I have not compiled the program, as it needs so more manual work.

Christen Fihl


http://HSPascal.Fihl.net


Quote:
> 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 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



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error msg 10019-Translate Error

2. Runtime error when running compiled program only

3. pascal program hangs although no compiling errors

4. Error msg: Not enough memory...

5. What does this Error msg indicate?

6. FILE NOT OPENED ERROR MSG

7. Unexpected heap overflow in protected mode program compiled by BP7

8. compile error - help please

9. compile error - help!

10. Interbase config - can't compile (password error)

11. -lvga error from svgalib demos compile

12. Unclear compile error...

 

 
Powered by phpBB® Forum Software