Storing stuff
#3
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.  Wink
Reply


Messages In This Thread
Storing stuff - by NasaCow - 12-14-2022, 10:42 AM
RE: Storing stuff - by mdijkens - 12-14-2022, 01:26 PM
RE: Storing stuff - by SMcNeill - 12-14-2022, 02:17 PM
RE: Storing stuff - by NasaCow - 12-14-2022, 02:31 PM
RE: Storing stuff - by SpriggsySpriggs - 12-14-2022, 04:40 PM
RE: Storing stuff - by Pete - 12-14-2022, 08:04 PM
RE: Storing stuff - by TempodiBasic - 12-14-2022, 11:39 PM
RE: Storing stuff - by NasaCow - 12-15-2022, 06:05 AM
RE: Storing stuff - by Pete - 12-15-2022, 11:51 AM
RE: Storing stuff - by mdijkens - 12-15-2022, 12:26 PM
RE: Storing stuff - by SpriggsySpriggs - 12-15-2022, 02:36 PM
RE: Storing stuff - by bplus - 12-15-2022, 02:57 PM
RE: Storing stuff - by bplus - 12-15-2022, 04:08 PM



Users browsing this thread: 4 Guest(s)