i have designed a database an one of my feilds is set up as an array. i had no problems reading my data into the array but i am having trouble trying to display the feild. when compiling the following error occurs.

error 88 expected (.
the error occurs in the section where the text color has been changed

below are the sections that i think are relevant to the problem:

program ordering;
uses crt;
type ordertype = array[1..8] of string[25];

order = record
memberid:string[10];
orderref:string[10];
address1:string[20];
noveg:integer;
nononveg:integer;
orderdate:string[10];
orderdetail : ordertype ;
pricepp:real;
totalprice:real;
discount:string[3];
finalprice:real;
end;
intfiletype1 = file of order;
extfilenametype1 = string [25];


procedure enterrecdata1 (var memrecord : order);
var i:integer;
hold: ordertype;
begin
writeln;
with memrecord do
begin
writeln ('Enter Member ID: ');
write ('Press the enter key to end input:');
readln (memberid);
if memberid <> ''
then
begin
write ('Enter Order Ref: ');
readln (orderref);
write ('Enter number of veggie people: ');
readln (noveg);
write ('Enter number of non veg: ');
readln (nononveg);
write ('Enter date of order: ');
readln (orderdate);
write ('Enter order: ');
for i:= 1 to 8 do
readln (orderdetail);
write ('Enter price per person: ');
readln (pricepp);
totalprice:=((nononveg) + (noveg)) * (pricepp) ;
writeln ('Discount?: ');
write ('*If yes type Y If no type N*');
readln (discount);
if discount = 'n' then (finalprice) := (totalprice)
else finalprice := totalprice * 0.90
end
end
end;

procedure display1;

var memrecord : order;
intfile : intfiletype1;
masterfile : extfilenametype1;
x:integer;
begin
clrscr;
gotoXY (15,1);
writeln ('-----MEMBERS FILE-----');
gotoXY (10,3);
getmasterfilename1 (masterfile);
gotoXY (1,5);
assign (intfile, masterfile);
reset (intfile);
while not eof (intfile) do
begin
read (intfile, memrecord);
with memrecord do
begin
x:=0;
repeat
clrscr;
writeln ('Member ID: ',memberid);
writeln ('Order REF: ',orderref);
writeln('Number of veg People: ' ,noveg);
writeln('Number of Non veg people: ' ,nononveg);
writeln ('Date of order: ',orderdate);
writeln ('Order: ',ordertype);
writeln('Price per Person:œ',pricepp:8:2);
writeln('Total Price:œ',totalprice:8:2);
writeln('Discount?: ',discount);
writeln('Final Price: œ',finalprice:8:2);
x:=x+1
until (x=8) or (eof(intfile));
readln;
end
end;

please help!! thank you

Dani AI

Generated

Short answer: the compiler was being given a type or an entire array where an expression was expected. was right to call out the loop index — printing array contents requires indexing each element and the index must be declared in the same procedure. solved the immediate problem by switching to a loop; the safer, clearer pattern is shown below.

Declare the loop variable in the display procedure and iterate the record field (not the type name). Example pattern:

var
  i: Integer;
begin
  for i := Low(memrecord.orderdetail) to High(memrecord.orderdetail) do
  begin
    if memrecord.orderdetail[i] <> '' then
      writeln('Order item ', i, ': ', memrecord.orderdetail[i]);
  end;
end;

Notes and troubleshooting tips:

  • Always declare i (or whatever index) in the var section of the procedure that uses it. Variables declared in one procedure are not visible in another.
  • Prefer Low(..)/High(..) instead of hard-coded 1..8; this avoids magic numbers and adapts if the type changes.
  • Skip empty entries (check for '') if some array slots may be unused. Alternatively, keep a separate count of used entries in the record for faster, unambiguous output.
  • The specific "expected ('" error commonly happens when the compiler encounters a token that isn't an expression (for example a type identifier) where an expression is required. Confirm the code passes the field name with an index (e.g., orderdetail[i]) and not the type name.
  • Watch for stray characters or non-ASCII symbols inside string literals; older Pascal compilers can choke on unexpected characters and emit confusing parse errors.

These small changes make the display code more robust and easier to maintain.

Recommended Answers

All 3 Replies

what is 'i' in that procedure? It's undefined...

i have now defined 'i' as an integer as it is above in procedure enterrecdata1 but still the same error occurs. any more ideas thanks for the help jwenting

i have solved the problem the following code is correct. the highlighted section is the changed part.

procedure display1;

var memrecord : order;
intfile : intfiletype1;
masterfile : extfilenametype1;
x:integer;
begin
clrscr;
gotoXY (15,1);
writeln ('-----MEMBERS FILE-----');
gotoXY (10,3);
getmasterfilename1 (masterfile);
gotoXY (1,5);
assign (intfile, masterfile);
reset (intfile);
while not eof (intfile) do
begin
read (intfile, memrecord);
with memrecord do
begin
x:=0;
repeat
clrscr;
writeln ('Member ID: ',memberid);
writeln ('Order REF: ',orderref);
writeln('Number of veg People: ' ,noveg);
writeln('Number of Non veg people: ' ,nononveg);
writeln ('Date of order: ',orderdate);
for i := 1 to 8 do
writeln ('Order: ',orderdetail);writeln('Price per Person:œ',pricepp:8:2);
writeln('Total Price:œ',totalprice:8:2);
writeln('Discount?: ',discount);
writeln('Final Price: œ',finalprice:8:2);
x:=x+1
until (x=8) or (eof(intfile));
readln;
end
end;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.