0% found this document useful (0 votes)
14 views3 pages

Binary File Processing

The document outlines a process for storing and managing student records in a serial file format. It includes steps for entering student details, saving them to a file, and allowing for the insertion of new records while maintaining order based on register numbers. Additionally, it describes how to create a new file, transfer existing records, and replace the old file with the updated one.

Uploaded by

ekta chawla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Binary File Processing

The document outlines a process for storing and managing student records in a serial file format. It includes steps for entering student details, saving them to a file, and allowing for the insertion of new records while maintaining order based on register numbers. Additionally, it describes how to create a new file, transfer existing records, and replace the old file with the updated one.

Uploaded by

ekta chawla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Storing records in a serial file

TYPETstudentRecord
DECLARE name : STRING
DECLARE registerNumber : INTEGER
DECLARE dateOfBirth : DATE
DECLARE fullTime : BOOLEAN
ENDTYPE
DECLARE studentRecord : ARRAY[1:50] OF TstudentRecord
DECLARE studentFile : STRING
DECLARE counter : INTEGER
counter ← 1
studentFile ← "[Link]"
OPEN studentFile FOR WRITE
REPEAT
OUTPUT "Please enter student details"
OUTPUT "Please enter student name"
INPUT studentRecord[counter].name
IF [Link] <> "" THEN
OUTPUT "Please enter student’s register number"
INPUT studentRecord[counter].registerNumber
OUTPUT "Please enter student’s date of birth"
INPUT studentRecord[counter].dateOfBirth
OUTPUT "Please enter True for fulltime or False for part-time"
INPUT studentRecord[counter].fullTime
PUTRECORD studentFile, studentRecord[counter]
counter ← counter + 1
ENDIF
UNTIL [Link] = ""
CLOSEFILE(studentFile)
OUTPUT "The file contains these records: "
OPEN studentFile FOR READ
counter ← 1
REPEAT
GETRECORD studentFile, studentRecord[counter]
OUTPUT studentRecord[counter].registerNumber
OUTPUT studentRecord[counter].dateOfBirth
OUTPUT studentRecord[counter].fullTime
counter ← counter + 1
UNTIL EOF(studentFile)
CLOSEFILE(studentFile)

DECLARE studentRecord : TstudentRecord


DECLARE newStudentRecord : TstudentRecord
DECLARE studentFile : STRING
DECLARE newStudentFile : STRING
studentFile ← "[Link]"
newStudentFile ← "[Link]"
CREATE newStudentFile // creates a new file to write to
OPEN newStudentFile FOR WRITE
OPEN studentFile FOR READ
OUTPUT "Please enter student details"
OUTPUT "Please enter student name"
INPUT [Link]
OUTPUT "Please enter student’s register number"
INPUT [Link]
OUTPUT "Please enter student’s date of birth"
INPUT [Link]
OUTPUT "Please enter True for full-time or False for part-time"
INPUT [Link]
REPEAT
// gets record from existing file
GETRECORD studentFile, studentRecord
IF [Link] > [Link]
AND NOT EOF(studentFile)
// writes record from existing file to new file
PUTRECORD newStudentFile ,studentRecord
ENDIF
UNTIL [Link] < [Link]
OR EOF(studentFile)
// writes new record to new file in the correct place
PUTRECORD newStudentFile ,newStudentRecord
IF NOT EOF (studentFile)
THEN
REPEAT
PUTRECORD newStudentFile , studentRecord
GETRECORD studentFile, studentRecord
UNTIL EOF(studentRecord)
ENDIF
CLOSEFILE(studentFile)
CLOSEFILE(newStudentFile)
DELETE(studentFile)// deletes old file of student records
RENAME newStudentfile, studentfile// renames new file to be the student record file

You might also like