Is the WriteInt function supposed to do this? (SOLVED)

Started by Gregjazz, Tue 22/11/2005 06:52:15

Previous topic - Next topic

Gregjazz

When I use the WriteInt function it actually writes something extraneous at the beginning of each data portion I write.

So if I do this:

Code: ags

File *output = File.Open("test.txt", eFileWrite);
output.WriteInt(5);
output.Close();


And then load the output file in Hexedit, I see this:

Code: ags

49 05 00 00 00                I . . . .


How can I get rid of it? Why is it there?

Kweepa

The 'I' is there to indicate to the ReadInt function that indeed the value written to the file was an Int.
Unfortunately there doesn't seem to be a WriteRawInt function to correspond to ReadRawInt.
You could simulate it with WriteRawChar, like so:
Code: ags

function WriteRawInt(File *output, int intToWrite)
{
Ã,  output.WriteRawChar(intToWrite & 255);
Ã,  output.WriteRawChar((intToWrite>>8) & 255);
Ã,  output.WriteRawChar((intToWrite>>16) & 255);
Ã,  output.WriteRawChar((intToWrite>>24) & 255);
}
Still waiting for Purity of the Surf II

Gregjazz

Success! I've never been happier. It's 12:33 AM and I finally finished this project I've been struggling with.

Thank you everyone for your emmense help!

SMF spam blocked by CleanTalk