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.

Subscribe to TECHLASS by Email

Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:

HTML Link Code:

BB (forum) link code:

Share on Google Plus

About Grace Joseph

Grace Joseph is from Cross River State, Nigeria. She studied Computer Science in University of Calabar and has great passion for writing, technology and blogging.


Post a Comment