Request
Blitz3D Forums/Blitz3D Programming/Request
| ||
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. |
| ||
There is a ReadInt command already. |
| ||
ReadByte ReadBytes ReadFloat ReadInt (readlong) ReadLine ReadShort ReadString What else do you want? |
| ||
They work fine for me! What are you trying to do? Wanna post some code if you're havin trouble??? |
| ||
For file IO you have to interpret the machine code directly. 11000010010100010111101010010101010101011010010010110100010111010100101010100101010100101010101010010110110011101000 |
| ||
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? |
| ||
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() |
| ||
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. |
| ||
:( |
| ||
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. |
| ||
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 "{}" |
| ||
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. |
| ||
:| |
| ||
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 |
| ||
no, it doesn't work, dunno why though. |