Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
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.

This determines my future in information technology .reply promptly

GHost182GHost182 Posts: 5Member
I am currently doing information technology in school and I need to hand in my School Based Assesment (SBA) assignment. I have done a program in which I used an array of records. I need to sort and edit the data, but so far I cannot get either one of them to work. Please help.I am required to use Turbo Pascal to do the assignment. Here is a sample of the declaraton and body of the program I have written, if it might help. I am only a begginer, so it might look a bit simple.

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);{ To sort the arrays above... I want to do them one at a time}
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.