-
storage of data
hi,
I'm writing a footy manager game and i wanted some help on how to store the data, as you can imagine there will be quite a lot(15 or so attributes for each player).
A team would be made up of a number of players(so a file or table for each team?)
I think I have 3 options. 1, a database(done in Access). 2, Store the data in random access files, and 3, store the data in flat text files.
Just wanted your advice on which one you would use and any hints on how best to implement it.
Thanks
Nick.
p.s. I was thinking of doing it using random access files.
-
2. Random File Access!!
The best step inbetween BAD files and GOOD databases.
Why I suggest this method is you can implement the UDTs right in without seperating them:
Code:
Dim Players(5) as myUDT
Put #1, 1, Players(5)
And then you can retrieve them in the same way:
Code:
Dim Players(5) as myUDT
Get #1, 1, Players(5)
This is why I suggest Random file access.
-
Random Access is very limited if you compare to Binary Access, that's why a suggest the later.
-
I think you should use a flat file and open with binary access.
I would store the flatfile something like this :
david ginola,23,564,234,65,sajdi
ronaldo,34,543,645,23,jfsdj
robaldo,31,423,23,43,ewrjrj
Then for reading in values you'd just do something like :
Code:
Private Type playerType
Name As String
SomeInt1 As Integer
SomeInt2 As Integer
SomeInt3 As Integer
SomeInt4 As Integer
SomeString As String
End Type
Private Players() As playerType
Private Sub Form_Load()
Open "C:\players.dat" For Binary As #1
Dim strTemp As String
Dim strArray() As String
Dim strArray2() As String
Dim i As Long
ReDim Players(0)
strTemp = Input(LOF(1), 1)
strArray = Split(strTemp, vbCrLf)
For i = 0 To UBound(strArray)
strArray2() = Split(strArray(i), ",")
With Players(UBound(Players))
.Name = strArray2(0)
.SomeInt1 = strArray2(1)
.SomeInt2 = strArray2(2)
.SomeInt3 = strArray2(3)
.SomeInt4 = strArray2(4)
.SomeString = strArray2(5)
End With
ReDim Preserve Players(UBound(Players) + 1)
Next i
Close #1
End Sub