Skip to content

Commit aa01ea7

Browse files
committed
Filing Updates
1 parent 78515f5 commit aa01ea7

File tree

5 files changed

+115
-2
lines changed

5 files changed

+115
-2
lines changed

Text Filing/Text Filing - Implementations/Pseudocodes - Text Filing/Deleting A Rec.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ INPUT "Enter roll# to delete :", searchRollNo
2020

2121
// Open the original file for reading and a temporary file for writing
2222
OPENFILE "sRec.txt" FOR READ
23-
OPENFILE "temp.txt" FOR OUTPUT
23+
OPENFILE "temp.txt" FOR WRITE
2424

2525
// Loop through the file to find and skip the record to be deleted
2626
WHILE NOT EOF("sRec.txt")

Text Filing/Text Filing - Implementations/Pseudocodes - Text Filing/Editing A Rec.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ INPUT "Enter roll# to edit:", searchRollNo
2020

2121
// Open the original file for reading and a temporary file for writing
2222
OPENFILE "sRec.txt" FOR READ
23-
OPENFILE "temp.txt" FOR OUTPUT
23+
OPENFILE "temp.txt" FOR WRITE
2424

2525
// Loop through the file, editing the matching record and copying the rest
2626
WHILE NOT EOF("sRec.txt")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// PSEUDOCODE FOR ADDING A STUDENT RECORD TO A FILE
2+
// This pseudocode describes the process of collecting a student's information,
3+
// such as roll number, name, contact, fee amount, and fee payment status,
4+
// and then appending this data to an existing file. This is useful for maintaining
5+
// student records in a persistent format.
6+
7+
// Declare variables to store student information
8+
DECLARE sRecord : STRING
9+
DECLARE rollNo : INTEGER // To store the roll number of the student
10+
DECLARE sName : STRING // To store the name of the student
11+
DECLARE sContact : STRING // To store the contact information of the student
12+
DECLARE sFee : CURRENCY // To store the fee amount (using a currency data type)
13+
DECLARE isFeePaid : BOOLEAN // To store whether the fee has been paid or not
14+
15+
// Input student details from the user
16+
INPUT "Enter roll number: ", rollNo
17+
INPUT "Enter student name: ", sName
18+
INPUT "Enter student contact: ", sContact
19+
INPUT "Enter fee amount: ", sFee
20+
INPUT "Is fee paid? (true/false) ", isFeePaid
21+
22+
sRecord = rollNo & '#' & sName & '#' & sContact & '#' & sFee & '#' & isFeePaid
23+
24+
// Open the file named 'sRec.txt' in append mode to add new data at the end of the file
25+
OPENFILE "sRec.txt" FOR APPEND
26+
27+
// Write the student details to the file 'sRec.txt'
28+
WRITEFILE "sRec.txt", sRecord
29+
30+
// Close the file after writing to it
31+
CLOSEFILE "sRec.txt"
32+
33+
/*
34+
* ────────────────────────────────────────────────────────────────────────
35+
* Author: Zafar Ali Khan
36+
* Position: A and O Level Computer Science Teacher
37+
*
38+
* Description:
39+
* This code is part of my teaching material, created for the betterment of my students
40+
* and learners worldwide. It's intended to facilitate learning and understanding
41+
* of computer science concepts.
42+
*
43+
* Contact:
44+
45+
* LinkedIn: [https://www.linkedin.com/in/zakonweb](https://www.linkedin.com/in/zakonweb)
46+
* GitHub: [https://github.com/zakonweb](https://github.com/zakonweb)
47+
* ────────────────────────────────────────────────────────────────────────
48+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// PSEUDOCODE FOR DISPLAYING A SINGLE RECORD FROM A FILE
2+
// This pseudocode demonstrates how to read and display a single student record from a file.
3+
// It assumes that the file 'sRec.txt' contains student records and each record consists of
4+
// roll number, name, contact, fee amount, and fee payment status.
5+
// The pseudocode reads the first record from the file and displays its contents.
6+
7+
// Declare variables to store the student record
8+
DECLARE sRecord : STRING
9+
DECLARE rollNo : INTEGER // To store the roll number of a student
10+
DECLARE sName : STRING // To store the name of a student
11+
DECLARE sContact : STRING // To store the contact information of a student
12+
DECLARE sFee : CURRENCY // To store the fee amount
13+
DECLARE isFeePaid : BOOLEAN // To store the fee payment status
14+
DECLARE hashPos1, hashPos2 : INTEGER
15+
16+
// Open the file 'sRec.txt' in read mode
17+
OPENFILE "sRec.txt" FOR READ
18+
19+
// Read the first record from the file line
20+
READFILE "sRec.txt", sRecord
21+
hashPos1 = LOCATE('#', sRecord)
22+
rollNo = LEFT(sRecord, hashPos1-1)
23+
24+
hashPos2 = LOCATE(hashPos1+1, '#', sRecord)
25+
sName = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1)
26+
27+
hashPos1 = hashPos2
28+
hashPos2 = LOCATE(hashPos1+1, '#', sRecord)
29+
sContact = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1)
30+
31+
hashPos1 = hashPos2
32+
hashPos2 = LOCATE(hashPos1+1, '#', sRecord)
33+
sFee = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1)
34+
35+
hashPos1 = hashPos2
36+
hashPos2 = LOCATE(hashPos1+1, '#', sRecord)
37+
IsFeePaid = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1)
38+
39+
// Output the details of the student record
40+
OUTPUT "Roll number: ", rollNo
41+
OUTPUT "Student name: ", sName
42+
OUTPUT "Student contact: ", sContact
43+
OUTPUT "Fee amount: ", sFee
44+
OUTPUT "Is fee paid? ", isFeePaid
45+
46+
// Close the file after reading
47+
CLOSEFILE "sRec.txt"
48+
49+
/*
50+
* ────────────────────────────────────────────────────────────────────────
51+
* Author: Zafar Ali Khan
52+
* Position: A and O Level Computer Science Teacher
53+
*
54+
* Description:
55+
* This code is part of my teaching material, created for the betterment of my students
56+
* and learners worldwide. It's intended to facilitate learning and understanding
57+
* of computer science concepts.
58+
*
59+
* Contact:
60+
61+
* LinkedIn: [https://www.linkedin.com/in/zakonweb](https://www.linkedin.com/in/zakonweb)
62+
* GitHub: [https://github.com/zakonweb](https://github.com/zakonweb)
63+
* ────────────────────────────────────────────────────────────────────────
64+
*/
65+

0 commit comments

Comments
 (0)