Request

Blitz3D Forums/Blitz3D Programming/Request

David819(Posted 2004) [#1]
It would be useful to have more file reading command in blitz like readlong and such, for those trying to read game data file and make their own.


Robert(Posted 2004) [#2]
There is a ReadInt command already.


Rob Farley(Posted 2004) [#3]
ReadByte
ReadBytes
ReadFloat
ReadInt (readlong)
ReadLine
ReadShort
ReadString

What else do you want?


_PJ_(Posted 2004) [#4]
They work fine for me! What are you trying to do? Wanna post some code if you're havin trouble???


jhocking(Posted 2004) [#5]
For file IO you have to interpret the machine code directly.
11000010010100010111101010010101010101011010010010110100010111010100101010100101010100101010101010010110110011101000


David819(Posted 2004) [#6]
I'm having the main problem with string at present in a file i am reading there are lots of other formats each the size of 4 but can only read on file format with a pile of other things after it, how do i read the other formats?


David819(Posted 2004) [#7]
oh, and here is my code for the file so far:
Graphics 640,480,32,2

File=ReadFile("level0_Final.dat")

SeekFile(file,20)

librects=ReadInt(file)
block1=ReadInt(file)
block2=ReadInt(file)
datastart=ReadInt(file)
datasize=ReadInt(file)
nameoffset=ReadInt(file)
namesize=ReadInt(file)
unknown=ReadInt(file)*ReadInt(file)


testt=ReadInt(file)
test$=ReadString(file)+testt


SeekFile(file,4)
;offset=Read

Print librects
Print block1
Print block2
Print datastart
Print datasize
Print nameoffset
Print namesize
Print unknown

Print test$
Print test1$

WaitKey()


David819(Posted 2004) [#8]
Oh, i almost forgot if this does not mke anysence to you (i mean like what the file is about) i have the specs for it, i just need to know how to get the part i am on to work.


David819(Posted 2004) [#9]
:(


Nacra(Posted 2004) [#10]
Are you having trouble getting through this 'unknown' block of data down to testt?

unknown=ReadInt(file)*ReadInt(file)

testt=ReadInt(file)
test$=ReadString(file)+testt

It looks like unknown would fill a 2D array or image. What do you get out of testt and test$? zeros? I'd step through it with the debugger and try to orient myself in the file. If needed hack up the file by putting recognizable values in the different locations.

And you could upload a sample and spec if you wanted more help.


Rook Zimbabwe(Posted 2004) [#11]
Slightly OT-

Goober. I agree with you... but Nacra has a good point. You can use the {codebox} code goes here... {/codebox} command to load a lot of code without taking much scroll space in the topic... the "{" symbol is actually the bracket :[" ie: "[]" instead of "{}"


David819(Posted 2004) [#12]
ok thanks so far here are the file specs:
  == DAT - Oni ==
first is header (64b), then lib follows, then some unknown block1 & block2, then data and 
at the end there is a name block

name			offset			size		note


Header:
ident			0				20			1F 27 DC 33  DF BC 03 00  31 33 52 56  40 00 14 00  10 00 08 00
lib recs		20				4			long
block1 recs		24				4			long
block2 recs		28				4			long
data start		32				4			long
data size 		36				4			long
names offset	40				4			long
names size		44				4			long
?				48				4*4			longs

Lib Rec (20 bytes):
type			0				4			string
offset			4				4			relative
name offset		8				4			relative
size			12				4
?				16				2			short
?				18				2			short

Names Block Rec (? bytes):
type			0				4			string
name			4				?			ASCIZ string




with the testt and test$ the testt is to get a value in this case (4) and add it onto the test$ to display the file type but there are loads of files in it.


David819(Posted 2004) [#13]
:|


Nacra(Posted 2004) [#14]
How about just jumping straight down into your lib block; skip all of that other reading for now. Does this get you the 'type' value?


SeekFile(file,48+4*4+1)

type=ReadString(file)
;testt=ReadInt(file)
;test$=ReadString(file)+testt


David819(Posted 2004) [#15]
no, it doesn't work, dunno why though.