View Full Version : ReadString from BinaryFile

05 May 2008, 11:59 AM
Hello there,

i'm working on a script to read data from a binary file and import it to 3ds. The original file is created with an external tool, so i must respect the specification. The file has data in byte, long, float and string formats so i open it as a BiniStream.

All work fine, i read some floats and integer from the header, but after read the string, all the data is wrong.

I've been investigating and the string on the file come without EOL char, so if read N bytes in a loop, where N is the string length, all is fine again.

But now, what i have is a string with the ASCII code of each char! Something named as #(84, 105, 97) isnt intuitive, and the worst is that i need that name to load a texture from file.

How can i parse with maxscript each byte as char. ( 84 as string returns "84").

Thanks in advance.


05 May 2008, 03:13 AM
Mate, I don't really know if this what you want, but it should do the job
bit.intAsChar 84 -- "T"

05 May 2008, 07:55 AM
Yeah! that's what i was i looking for :). I've tested it at the listener:

str = bit.intAschar stringasbyte[1] + bit.intAschar stringasbyte[2] + bit.stringasbyte[3]

Returns "Tia" :)

Thanks you a lot mate.


CGTalk Moderation
05 May 2008, 07:55 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.