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.

post some code of what you've tried on reading data process.
also how that file is some kind of datafile when it's extension is .txt?

The infiles we have always used in class were .txt files, so I'm not sure if there would be a problem there.

As for the coding, like I said before I am really stumped. I tried something really simple but it still makes my outfile blank.

Read (Infile, ch);

Writeln (OurClass.FirstName[1]);

Write (outfile, ch);

Yes, I know, I am semi-retarded haha. Just hope someone gives me advice that clicks.

This article has been dead for over six months. Start a new discussion instead.