Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Ineed help

GHost182GHost182 Posts: 5Member
I am currently doing my School Based Assesment (SBA) and I have created an
array of records. In order to complete the assignment, I need to be able to edit these records. Everywhere else that I checked is useless. Can you help me? Here is a sample of the code if that might help(Turbo Pascal). I also cannot get sorting to work.

program librarything (input, output);
uses {win}crt;
type
memrec= record
fname:string;
lname:string;
other:string;
homeaddress:string;
form:string;
tel:char;
parent:string;
partel:char;
powork:string;
end;
brec= record
fname:string;
lname:string;
bkname:string;
duedate:string;
nowdate:string;
end;
memarray= packed array[1..20] of memrec;
memrecfile= file of memrec;
borarray= packed array[1..20] of brec;
brecfile= file of brec;
var
memray:memarray;
rtemp:memrecfile;
btemp:brecfile;
reginfo:memrec;
regfile:memrecfile;
binfo:brec;
bfile:brecfile;
size:integer;

{*************************************************************************************************}
PROCEDURE SortArray(var memray:memarray; var regfile:memrecfile);
VAR
location,index,size:INTEGER;
current:memrec;
BEGIN
reset (regfile);
size:=1;
WHILE NOT EOF (regfile) DO
BEGIN
read(regfile,memray[size]);
size:=size+1;
END;
reset (regfile);



FOR index:= 2 TO size-1 DO
BEGIN
current:=memray[index];
location:=index;
WHILE (location > 1) AND (memray[location-1].fname < current.fname) DO
BEGIN
memray[location]:=memray[location-1];
location:=location-1;
END;
memray[location]:=current;
END;

rewrite(regfile);
FOR index:= 1 TO size-1 DO
BEGIN
write(regfile,memray[index]);
END;
reset(regfile);

END;

{*************************************************************************************************}

begin{main}
assign(regfile,'F:I.T. SbaPascal
egisternew');
assign(bfile,'F:I.T. SbaPascalorrow');
assign(rtemp,'F:I.T. SbaPascal
temp');
assign(btemp,'F:I.T. SbaPascaltemp');
{rewrite(regfile);
rewrite(rtemp);}
SortArray(memray,regfile);
end.
Sign In or Register to comment.