Tut for @johnno56
Breaking the ice with Random access
Breaking the ice with Random access
Code: (Select All)
'Tutorial (with help from Wiki):
' save this bas file in the folder where you want you BloodData.dat file to go first!
Type Blood
date As String * 10
level As Integer
comment As String * 50
End Type
'Make a record:
Dim Shared Record As Blood, lenRecord&, nRecs&
lenRecord& = Len(Record)
' start up the data file
Open "BloodData.dat" For Random As #1 Len = lenRecord&
Record.date = "2022/11/18"
Record.level = 101
Record.comment = "This is my comment."
'Store a record:
Put #1, 1, Record
nRecs = LOF(1) / lenRecord&
Print "number recs:"; nRecs ' good 1 lets get it
' get record
Get #1, 1, Record
Print Record.date; ":"; Record.level; ", "; Record.comment
' stick another record in there
nRecs = nRecs + 1
Record.date = "2022/11/19"
Record.level = 105
Record.comment = "This is my next comment."
Put #1, nRecs, Record
' check records
nRecs = LOF(1) / lenRecord&
Print "number recs:"; nRecs ' good 2 lets see em
For i = 1 To nRecs
Get #1, i, Record
Print Record.date; ":"; Record.level; ", "; Record.comment
Next
b = b + ...