Hello, I'm sort of new to Pascal and I am not very good at it haha, but records just make me even more oblivious. The program we use in class is TMT Pascal 4 Multi-Target.
My teacher is out for the week and I really need help on this program because I don't understand how to use records.
Basically, the program is a database using a datafile that my teacher provided us that incorporate First Name, Favorite Color, Age, Shoe Size, and Favorite Sport. (Infile, Outfile)
An example of an entry in the infile is as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reginald Red 16 12 Golf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The code I have right now is very basic because I can't figure out how to read or sort records using arrays.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Program Database (Infile, Outfile);
Type
Student = Record
FirstName: String;
FavColor: String;
Age: Integer;
Shoe: Real;
FavSport: String;
End; {Record}
OurClass = Array[1..20] of Student;
Var
Class: Ourclass; {Variable for Student Array}
PlaceCount, MinIndex, PassCount: Integer; {Local Control Variables}
Count, LCV: Integer; {Counter and Local Control Variable}
Ch: Char; {Variable for ch}
TempS: String; {Temporary Variable for String}
TempI: Integer; {Temporary Variable for Integer}
TempR: Real; {Temporary Variable for Real}
Infile, Outfile: Text; {Sends Info from Infile to Outfile}
Procedure FindData (Var Infile, Outfile: Text);
Begin {FindData}
{Need Some Help here lol}
End; {FindData}
Begin {Main}
Writeln ('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
Writeln ('Database Program');
Writeln ('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
assign (Infile,'f:\DB07.txt');
reset (Infile);
assign (Outfile,'f:\dataout.txt');
rewrite (outfile);
writeln;
FindData (Infile, Outfile);
writeln;
End. {Main}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am assuming I will have to make seperate procedures for each of the sorts, so any snippets could be potentially benefical for me.
My teacher wants us to make an option at the beginning of the program that will allow us to sort the data by either FirstName, FavColor, Age, Shoe, or FavSport.
Any help is greatly appreciated and I thank you for your time! I want to try and hand this in by Tuesday, so any suggestions would be wonderful!
My first step is actually reading the data on my infile and sending it to the outfile, but everything I've tried hasn't worked v_v.