EDIT: seraphelic omg i swear to god i didn't steal your idea sorry mate i did this then posted it and looked at the other topics and i was like WTF! usually only people who get stoned have the same ideas as me.
i haven't been on here in years, man this forum has changed so much :S
YOU CAN EDIT THIS WITH NOTEPAD
This is my code, (it can save 1000 strings in 5 milliseconds WOOT!). Anyway that's all and good but i was just wondering if there was a better way of doing it? or a way to optimize it faster? any changes? its not quite finished yet... im gonna use pointers
Also theres one more feature i need to add in each function. one can save an array but can't save In an array, the other can only do the opposite (but loading), just need to pull the codes over basically. Although you can do without quite easily it just won't be as fast.
You can also select which pieces of data from the file to load into memory.
Save a piece of data without having to save the whole file all over again.
EDIT: The position of the data and length isn't saved in the db but calculated by good old but FAST assembly.
Code:
ttime1 = GetTickCount()
Call SaveEditBin("bakekitsune", "data", "IAMDATA", 1000)
ttime2 = GetTickCount()
Call SaveEditBin("bakekitsune", "time", CStr(ttime2 - ttime1))
MsgBox LoadEditbin("bakekitsune", "data", 543)
omg make the code box bigger!
Code:
Sub SaveEditBin(Name As String, Var As String, Val As String, Optional ByRef ArraySize As Long, Optional ByRef nFileNum As Byte)
Dim i As Long, dbpos As Long
If nFileNum = 0 Then
nFileNum = FreeFile
If ArraySize = 0 Then
Open App.Path & "\" & Name & ".txt" For Binary Access Write Lock Read Write As #nFileNum
Put #nFileNum, AscW(Var) * MAX_CHARS, sC & Var & "=" & Val
Close #nFileNum
Else
dbpos = AscW(Var) + 255
Open App.Path & "\" & Name & ".txt" For Binary Access Write Lock Read Write As #nFileNum
For i = 0 To ArraySize
Put #nFileNum, (dbpos + i) * MAX_CHARS, sC & Var & i & "=" & Val
Next i
Close #nFileNum
End If
End If
End Sub
Function LoadEditbin(Name As String, Var As String, Optional ByRef ArrayNum As Long) As String
Dim nFileNum As Byte, dbcompile As String, dbArray() As String
If ArrayNum = 0 Then
nFileNum = FreeFile
Open App.Path & "\" & Name & ".txt" For Binary Access Read Lock Read Write As #nFileNum
dbcompile = Space$(MAX_CHARS)
Get #nFileNum, AscW(Var) * MAX_CHARS, dbcompile
Close #nFileNum
Else
nFileNum = FreeFile
Open App.Path & "\" & Name & ".txt" For Binary Access Read Lock Read Write As #nFileNum
dbcompile = Space$(MAX_CHARS)
Get #nFileNum, (AscW(Var) + ArrayNum + 255) * MAX_CHARS, dbcompile
Close #nFileNum
End If
dbArray() = Split(dbcompile, "=", MAX_CHARS, vbBinaryCompare)
LoadEditbin = dbArray(1)
End Function
Result: Text file with (you can edit with Notepad and it will come up with the right result)
Code:
time=05
data0=IAMDATA
data1=IAMDATA
data2=IAMDATA
data3=IAMDATA
etc...x1000
In this case data543=IAMDATA if i change data543=OH!YEAH in notepad, then if you ask for data543 then you get OH!YEAH .
>>> PS: Props to Sepiroth for giving me my first lesson in binary ( Yes i optimized it with NO dope! or NOdoze... i always get confused between the two
EDIT: oh yeh kids don't take drugs its NOT cool)
If your gonna tax this code i dunno put like Bakekitsune's Editable BinDB anyway reference me or i will stab u!
_________________
______________________________________________________________________________
www.animephantom.com