Pascal Program to Create and Save Records in a Textfile

program Create_Records;
Gra = String [30];
File_Content = Record
Name : Gra;
Matric_No : Gra;
Dept : Gra;
Sex : Gra;
Date_Of_Birth : Gra;
(*enter as many data as you like and intialise either as string, integer or char*);

       FileInfo : File_Content;
       Newfile : text;
        I : Integer;

Assign (newfile, 'Grace_Joseph.txt');
rewrite (Newfile);
      for i := 1 to 5 do
      writeln ('Enter name:');
      readln (;
       writeln ('matric number');
       readln (fileinfo.matric_No);
        writeln ('department');
       readln (fileinfo.dept);
        writeln ('sex');
        readln (;
        writeln ('date of  birth');
        readln (fileinfo.date_of_birth);
(*follow the above procedure to write and read the data you initialised*    )

writeln (newfile,' Name:',
writeln (newfile, 'matric number:', fileinfo.matric_no);
writeln (newfile,' Department: ', fileinfo.dept);
writeln (newfile,' Sex:',;
writeln (newfile,' Date Of Birth:', fileinfo.date_of_birth);
close (newfile);

In the program above, students records are saved in a textfile. You can rename the name of the textfile from Grace_Joseph.txt to yourDesired Name.txt. Goto the documents in your computer and search for the file using. the filename.txt.

The program creates a record for 5 students using the For Do loop.

Share on Google Plus

About Grace Joseph

Grace Joseph is a tech blogger from Cross River State, Nigeria. She studied Computer Science in University of Calabar and is a lover of tech, music and the Internet. You can follow her on Facebook and Google+


Post a Comment