Quote: "Grog, I didn't enter either of those, as the File commands are already there, you just need to utilize them, and there are already DLLs to do the tasks you want ( why bother TGC adding commands that you already have available when they can better spend their time bug beating, or adding commands that we DONT have already? )"

You act like i'm some irate newbie that's just making trouble. Yes, i'm a newbie to Darkbasic but not to programming. I didn't ask for this lightly. This is something that we can all benifit from not just me. Because I know this is possible why not ask for it? This is after all a thread where we can put suggestions in for the next upgrade. Just because we can do it "the hard way" doesn't mean TGC can't make an easy way. Why buy a .dll when it could be put into Darkbasic?
Quote: "The UDTs thingo. That just isn't going to happen.
DB's a BASIC language for game creation, you're lucky to have UDTs at all in the first place. To implement something like that ( which you yourself can code quite easily and painlessly ) is just another waist of time."
I don't buy that excuse that we're "lucky to have UDT's". I know for a fact it's possible because UDT's with an exact nature are in Quickbasic. Quickbasic was made in 1985... Darkbasic 1999. So if a program that was around 14 years before Darkbasic was even made can do it... i'm sure Darkbasic can have the same ability.
Quote: "That looks like either a bug to me, or one of those "Just the way it is" things... Post it in Bug Reports, not here."
I posted it here to be on the safe side because I wasn't sure if it was really a bug or not.
I probably haven't been clear enough for everybody to realize the value of what i'm asking for... so i've made a little example of what it is and what it could be.
I play a game called Paranoia. In Paranoia there is an outragious amount of data just for the players themselves. I figured i'd show a little of that data (to get everything I had to add another 60 lines for each UDT, read, and write... which is 180 more lines of code).
Now I call this "the hard way" because I know TGC could add a better way:
` Define Data
type PlayerData
PlayerName as string
CharacterName as string
Clearance as integer
Sector as string
Credits as integer
Clone as integer
Gender as integer
MBD as integer
Bootlicking as integer
Chutzpah as integer
Hygiene as integer
Interrogation as integer
Intimidation as integer
Moxie as integer
Oratory as integer
Concealment as integer
Disguise as integer
HighAlert as integer
SecuritySystems as integer
Shadowing as integer
endtype
dim D1(9) as PlayerData
` Write Data
open to write 1,"Test.dat"
for t=0 to 9
D1(t).PlayerName = "Grog Grueslayer "
D1(t).CharacterName = "Cluste "
D1(t).Clearance = 1
D1(t).Sector = "BOM"
D1(t).Credits = rnd(5000)
D1(t).Clone = rnd(5)+1
D1(t).Gender = rnd(10)
D1(t).MBD = rnd(10)
D1(t).Bootlicking = rnd(10)
D1(t).Chutzpah = rnd(10)
D1(t).Hygiene = rnd(10)
D1(t).Interrogation = rnd(10)
D1(t).Intimidation = rnd(10)
D1(t).Moxie = rnd(10)
D1(t).Oratory = rnd(10)
D1(t).Concealment = rnd(10)
D1(t).Disguise = rnd(10)
D1(t).HighAlert = rnd(10)
D1(t).SecuritySystems = rnd(10)
D1(t).Shadowing = rnd(10)
write string 1,left$(D1(t).PlayerName,25)
write string 1,left$(D1(t).CharacterName,25)
write long 1,D1(t).Clearance
write string 1,left$(D1(t).Sector,3)
write long 1,D1(t).Credits
write long 1,D1(t).Clone
write long 1,D1(t).Gender
write long 1,D1(t).MBD
write long 1,D1(t).Bootlicking
write long 1,D1(t).Chutzpah
write long 1,D1(t).Hygiene
write long 1,D1(t).Interrogation
write long 1,D1(t).Intimidation
write long 1,D1(t).Moxie
write long 1,D1(t).Oratory
write long 1,D1(t).Concealment
write long 1,D1(t).Disguise
write long 1,D1(t).HighAlert
write long 1,D1(t).SecuritySystems
write long 1,D1(t).Shadowing
next t
close file 1
` Clear Data
for t=0 to 9
D1(t).PlayerName = ""
D1(t).CharacterName = ""
D1(t).Clearance = 0
D1(t).Sector = ""
D1(t).Credits = 0
D1(t).Clone = 0
D1(t).Gender = 0
D1(t).MBD = 0
D1(t).Bootlicking = 0
D1(t).Chutzpah = 0
D1(t).Hygiene = 0
D1(t).Interrogation = 0
D1(t).Intimidation = 0
D1(t).Moxie = 0
D1(t).Oratory = 0
D1(t).Concealment = 0
D1(t).Disguise = 0
D1(t).HighAlert = 0
D1(t).SecuritySystems = 0
D1(t).Shadowing = 0
next t
` Read Data
open to read 1,"Test.dat"
for t=0 to 9
read string 1,D1(t).PlayerName
read string 1,D1(t).CharacterName
read long 1,D1(t).Clearance
read string 1,D1(t).Sector
read long 1,D1(t).Credits
read long 1,D1(t).Clone
read long 1,D1(t).Gender
read long 1,D1(t).MBD
read long 1,D1(t).Bootlicking
read long 1,D1(t).Chutzpah
read long 1,D1(t).Hygiene
read long 1,D1(t).Interrogation
read long 1,D1(t).Intimidation
read long 1,D1(t).Moxie
read long 1,D1(t).Oratory
read long 1,D1(t).Concealment
read long 1,D1(t).Disguise
read long 1,D1(t).HighAlert
read long 1,D1(t).SecuritySystems
read long 1,D1(t).Shadowing
` Print Data
cls
if D1(t).Clearance = 1 then c$="R"
for z=1 to len(D1(t).CharacterName)
if mid$(D1(t).CharacterName,z)=" "
D1(t).CharacterName=left$(D1(t).CharacterName,z-1)+"-"+c$+"-"+D1(t).Sector+"-"+str$(D1(t).Clone)
exit
endif
next z
print D1(t).PlayerName
print D1(t).CharacterName
print D1(t).Credits
print D1(t).Gender
print D1(t).MBD
print D1(t).Bootlicking
print D1(t).Chutzpah
print D1(t).Hygiene
print D1(t).Interrogation
print D1(t).Intimidation
print D1(t).Moxie
print D1(t).Oratory
print D1(t).Concealment
print D1(t).Disguise
print D1(t).HighAlert
print D1(t).SecuritySystems
print D1(t).Shadowing
wait key
next t
close file 1
I propose 3 commands and 1 command add-on:
open as binary filenumber,filename$
^ This allows reading or writing in a file without the need to close the file
read binary filenumber,variable (usually UDT),bytes to start
^ This reads all the data at once if it's a UDT... the bytes to start is optional... if it's not there Darkbasic assumes start at byte 1
write binary filenumber,variable (usually UDT),bytes to start
^ Same syntax but for writing data
PlayerName as string * 25
^ This tells Darkbasic that the string PlayerName is 25 characters. This is vital for read/write binary to work properly. There is no need to write code to take the string down/up to 25 characters. No matter what you say PlayerName equals it automatically add spaces or removes characters till it's 25 characters only.
The way Darkbasic is now it writes the full string (weither is it under 25 characters or not)... and as most of you know to load a binary file properly you have to know exactly how many characters to load from the binary file. If the UDT's are allowed to specify how many characters to use for each string it will be automatic and flawless.
Now with those commands available we can do this instead of the first code snip:
` Define Data
type PlayerData
PlayerName as string * 25
CharacterName as string * 25
Clearance as integer
Sector as string * 3
Credits as integer
Clone as integer
Gender as integer
MBD as integer
Bootlicking as integer
Chutzpah as integer
Hygiene as integer
Interrogation as integer
Intimidation as integer
Moxie as integer
Oratory as integer
Concealment as integer
Disguise as integer
HighAlert as integer
SecuritySystems as integer
Shadowing as integer
endtype
dim D1(9) as PlayerData
` Write Data
open as binary 1,"Test.dat"
for t=0 to 9
D1(t).PlayerName = "Grog Grueslayer"
D1(t).CharacterName = "Cluste"
D1(t).Clearance = 1
D1(t).Sector = "BOM"
D1(t).Credits = rnd(5000)
D1(t).Clone = rnd(5)+1
D1(t).Gender = rnd(10)
D1(t).MBD = rnd(10)
D1(t).Bootlicking = rnd(10)
D1(t).Chutzpah = rnd(10)
D1(t).Hygiene = rnd(10)
D1(t).Interrogation = rnd(10)
D1(t).Intimidation = rnd(10)
D1(t).Moxie = rnd(10)
D1(t).Oratory = rnd(10)
D1(t).Concealment = rnd(10)
D1(t).Disguise = rnd(10)
D1(t).HighAlert = rnd(10)
D1(t).SecuritySystems = rnd(10)
D1(t).Shadowing = rnd(10)
write binary 1,D1(t)
next t
close file 1
` Clear Data
for t=0 to 9
D1(t).PlayerName = ""
D1(t).CharacterName = ""
D1(t).Clearance = 0
D1(t).Sector = ""
D1(t).Credits = 0
D1(t).Clone = 0
D1(t).Gender = 0
D1(t).MBD = 0
D1(t).Bootlicking = 0
D1(t).Chutzpah = 0
D1(t).Hygiene = 0
D1(t).Interrogation = 0
D1(t).Intimidation = 0
D1(t).Moxie = 0
D1(t).Oratory = 0
D1(t).Concealment = 0
D1(t).Disguise = 0
D1(t).HighAlert = 0
D1(t).SecuritySystems = 0
D1(t).Shadowing = 0
next t
` Read Data
open as binary 1,"Test.dat"
for t=0 to 9
read binary 1,D1(t)
` Print Data
cls
if D1(t).Clearance = 1 then c$="R"
D1(t).CharacterName=D1(t).CharacterName+"-"+c$+"-"+D1(t).Sector+"-"+str$(D1(t).Clone
exit
endif
next z
print D1(t).PlayerName
print D1(t).CharacterName
print D1(t).Credits
print D1(t).Gender
print D1(t).MBD
print D1(t).Bootlicking
print D1(t).Chutzpah
print D1(t).Hygiene
print D1(t).Interrogation
print D1(t).Intimidation
print D1(t).Moxie
print D1(t).Oratory
print D1(t).Concealment
print D1(t).Disguise
print D1(t).HighAlert
print D1(t).SecuritySystems
print D1(t).Shadowing
wait key
next t
close file 1
Now which would you rather have? The way it is now... where each time you add a variable of data you have to add another line to read and another to write. So if your data is in a UDT with 80 different variables of data you have to add 80 lines for reading and 80 lines for writing. Vs what i'd like to see in Darkbasic... could be reduced down to 1 line for reading the entire block of data and 1 line for writing.
With the ability to read/write a binary file without closing, reopening, and searching the data one could do this:
` Give 3rd player 500 more credits
Record=3
open as binary 1,"Test.dat"
read binary 1,D1(Record),Record*121
inc D1(Record).Credits,500
write binary 1,D1(Record),Record*121
close file 1
The above opens the file,skips down to byte 363 and reads the player data into D1(3) (which Darkbasic knows based on the UDT's exact nature for the strings),then a single change is made, and written into the same exact location in the binary file.
What is required to do this in Darkbasic the way it is now? Open two files, read from the first file and write out the data to the second file until it gets to record 3, make the change, write the changed data, then continue to write the rest of the file till the end. Delete the old file, rename the new file to the old filename.
Again... the method we
have to use I call "the hard way". I know it could be better because of my Quickbasic experience... we can have it better if The Game Creators are willing to give it to us.
I don't have anything against you JessTicular... I just think you're overlooking how easy TGC could make file reading/writing in Darkbasic.
What do the rest of you think about simplifying the reading/writing of binary files?