12-14-2022, 02:31 PM
(12-14-2022, 02:17 PM)SMcNeill Wrote:Code: (Select All)'How to write my data
'StudentID:###...
'FirstName:$$$...
'LastName: $$$...
'START PERIOD: #
'START GRADES
'Grade: ###
'Note : $$$...
'Grade: ###
'Note : $$$...
'Grade: ###
'Note : $$$...
'END GRADES
'Average: ###
'Note : $$$...
'END PERIOD #
'Semester 1 Exam: ###
'Note : $$$...
'Semester 1 Avrg: ###
'Note : $$$...
'Semester 2 Exam: ###
'Note : $$$...
'Semester 2 Avrg: ###
'Note : $$$...
'Final Grade : ###
'Note : $$$...
'Note : $$$...
'Note : $$$...
'Note : $$$...
'End StudentID: ###...
This is a simple enough, and human enough, structure that you should be able to open up the data file in any text editor, and decipher the results. (In case some new system security feature or school rule makes your program not work in the future.)
The way I'd do this is to open my file FOR OUTPUT (Yes, that means it'd be overwritten each time I updated my records, but we're not talking 200GB databases here... Small data sets, small problems with rewriting them over and over!). Then I'd just PRINT my data on each line.
Code: (Select All)PRINT #1, "StudentID: "; StudentID
PRINT #1, "First Name: "; fname$
PRINT #1, "Last Name: "; lname$
FOR I = 1 TO NumberOfPeriods '1st Six Weeks is 1, 2nd Six Weeks is 2, 3rd Six Weeks is 3...
PRINT #1, "START PERIOD: "; I
PRINT #1, "START GRADES"
FOR J = 1 TO NumberOfGrades 'number in this period
PRINT #1, "Grade: "; Grade(J)
PRINT #1, "Notes: "; Notes(J)
NEXT
PRINT #1, "END GRADES"
PRINT #1, "Average: "; Average(I)
PRINT #1, "Notes: "; PeriodNotes(I)
PRINT #1, "END PERIOD: "; I
NEXT
...and then print the final results and semester exam/averages
Writing it in such a manner, I can then read it back with DO-LOOPS, so my data set can be as irregular as needed. I don't need to plan for 10 tests in the first 6 weeks. When it comes to input, the main process would be:
Code: (Select All)DO
count = count + 1
LINE INPUT #1, temp$
IF temp$ = "END GRADES" THEN EXIT DO
Grade(count) = VAL(MID$(temp$, INSTR(temp$, ":") +1)
LINE INPUT #1, temp$
Note(count) = MID$(temp$, INSTR(temp$, ":") +1
LOOP
Here, I read my data and assign it to my array -- and I'm reading it until I come across that END OF DATA type marker -- in this case, "END GRADES" and "END PERIOD". When I read the data file and see "START GRADES", I know I'm going to have a DO..LOOP where I read my data as GRADE, NOTE, each on a separate line. I continue to read GRADE, NOTE, until I finally come to that EOD marker "END GRADES", and then I can read what comes next in my data file. (In this case, the period average.)
StartOfData
grade
note
grade
note
grade
note
repeat as many times as you like with the grade then note...
EndOfData
^ This type structure doesn't have a hardcoded limit to it. It could contain 1 record, or it could contain 3000. What we know about it is that that data is always going to be in the format of GRADE on one line, followed by NOTE on the next line. We just read our data file line by line, checking for our EOD marker, and until we see it, we keep adding to our list.
It's a very simple type structure, but very flexible, and it molds itself quite well for use with variable length strings. I really think it'd be the way I'd go about storing the data you're talking about to my drive.
There are some good ideas and helped me think how I can be more flexible. When I said plan, I didn't mean for the teacher but for me. Already been scratching on paper on and off during my break time and decided I want a flag as well, for missing or late turn-in so I can do some color coding for easy reading. I just had to convert my data file over for my real students for the reports to add that UID for each one and that was a bit of a hassle. I guess I am trying to avoid that again.
I guess sometimes I get too caught up in being efficient sometimes with read and writes. You are right. I'd be surprised if any one of my files clear a MB or two. Thanks for helping out! I can't wait to share the next update with you all. It is coming along nicely!