Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving Items problem
#2
This is the system I use, that works just as good, saving each item in it's own file, like the maps do.

Code:
Sub SaveItems()
Dim i As Integer

For i = 1 To MAX_ITEMS
    If Not FileExist("data\items\item" & i & ".doi", True) Then
        Call SetStatus("Saving items... " & i & "/" & MAX_ITEMS)
        DoEvents
        Call SaveItem(i)
    End If
Next i

End Sub


Sub SaveItem(ByVal ItemNum As Integer)
Dim FileName As String
Dim f As Long
FileName = App.Path & "\data\Items\Item" & ItemNum & ".doi"

f = FreeFile
Open FileName For Binary As #f
Put #f, , Item(ItemNum)
Close #f
End Sub

Sub LoadItems()
Dim FileName As String
Dim i As Long, f As Long

    Call CheckItems

For i = 1 To MAX_ITEMS
    Call SetStatus("Loading items... " & i & "/" & MAX_ITEMS)
    FileName = App.Path & "\data\items\item" & i & ".doi"
    f = FreeFile
    Open FileName For Binary As #f
    Get #f, , Item(i)
Close #f

DoEvents
Next i

End Sub

Sub CheckItems()
    Call SaveItems
End Sub
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)