Notifications
Clear all

[Closed] ReadString from BinaryFile

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.

Pablo.

2 Replies

Mate, I don’t really know if this what you want, but it should do the job

bit.intAsChar 84 -- "T"

Shane

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.

Pablo.