Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

satans_banjo

macrumors regular
Original poster
Sep 12, 2005
218
0
SE London
Ok this is quite urgent - I've got some pascal work to do for tomorrow and the exercise is about file handling - problem is the teacher only told us about file handling on windows

i've tried writing the same thing i would for windows but replacing the file path with just "/" as the root but that didnt work. the compiler had no problems but the terminal did this when i ran it:

Loading...
Runtime error 2 at $00002354
$00002354
$0000274C
$00020954
$00001CAC
$00001B4C
$00000001

the weird thing is, i didn't put a string that says 'loading...' in the code. it must have been added by the compiler

any advice would be much appreciated
 

satans_banjo

macrumors regular
Original poster
Sep 12, 2005
218
0
SE London
thanks for the quick reply

here's the main part:

Code:
begin
     assign(f1,'/file.car');
     load;
     menu;
end.

heres the load procedure:

Code:
procedure load;
begin
     writeln('Loading Data Now...');
     reset(f1);
     i:=0;
     while not eof(f1) do
     	begin
     		i:=i+1;
     		seek(f1,i);
     		read(f1,car[i]);
     	end;
     close(f1);
     count:=i;
end;

and here's the save procedure

Code:
procedure save;
begin
     writeln('Saving data now...');
     rewrite(f1);
     for i:=1 ro count do
     begin
     	seek(f1,i);
     	write(f1,car[i]);
     end;
     close(f1);
end;

thanks for reading
 

satans_banjo

macrumors regular
Original poster
Sep 12, 2005
218
0
SE London
sorry. schoolboy error

this is the array, in the enterdata procedure:

Code:
procedure enterdata;
begin
     car[1].regnum := 'D390 HDJ';
     car[1].ownname:= 'Ben Wadsworth';
     car[1].make   := 'Bentley';
     car[1].model  := 'Continental GT';
     car[2].regnum := 'F387 DJK';
     car[2].ownname:= 'Alex Branchini';
     car[2].make   := 'Fiat';
     car[2].model  := 'Punto';
     car[3].regnum := 'G768 SKF';
     car[3].ownname:= 'Tom Scott-Soundy';
     car[3].make   := 'Hummer';
     car[3].model  := 'H2';
     car[4].regnum := 'B847 DJH';
     car[4].ownname:= 'Rory Dishman';
     car[4].make   := 'Mercedes-Benz';
     car[4].model  := 'S-Class';
     car[5].regnum := 'H487 FNS';
     car[5].ownname:= 'Josh Holloway';
     car[5].make   := 'Jaguar';
     car[5].model  := 'X-Type';
end;

and here is the new main section:

Code:
begin
     assign(f1,'/file.car');
     enterdata;
     save;
     load;
     menu;
end.

thanks for pointing that out

EDIT: just compiled it and it works!

thanks macrumors! and special thanks to robbieduncan and danny_w!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.