Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database
#13
Tut for @johnno56

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 + ...
Reply


Messages In This Thread
Database - by johnno56 - 11-18-2022, 08:44 AM
RE: Database - by mdijkens - 11-18-2022, 09:28 AM
RE: Database - by mnrvovrfc - 11-18-2022, 12:30 PM
RE: Database - by bplus - 11-18-2022, 01:35 PM
RE: Database - by SpriggsySpriggs - 11-18-2022, 02:13 PM
RE: Database - by Kernelpanic - 11-18-2022, 04:31 PM
RE: Database - by CharlieJV - 11-19-2022, 05:05 PM
RE: Database - by SMcNeill - 11-18-2022, 02:17 PM
RE: Database - by mdijkens - 11-18-2022, 02:37 PM
RE: Database - by bplus - 11-18-2022, 03:16 PM
RE: Database - by Kernelpanic - 11-18-2022, 03:38 PM
RE: Database - by johnno56 - 11-18-2022, 08:45 PM
RE: Database - by mnrvovrfc - 11-18-2022, 11:26 PM
RE: Database - by bplus - 11-19-2022, 01:04 AM
RE: Database - by mnrvovrfc - 11-19-2022, 04:59 PM
RE: Database - by bplus - 11-19-2022, 05:58 PM
RE: Database - by johnno56 - 11-19-2022, 08:02 PM
RE: Database - by bplus - 11-19-2022, 08:11 PM
RE: Database - by Pete - 11-20-2022, 06:55 AM
RE: Database - by mnrvovrfc - 11-20-2022, 08:17 PM
RE: Database - by bplus - 11-20-2022, 08:58 PM



Users browsing this thread: 1 Guest(s)