You must be logged in to do that.

FileWriteByte

FileWriteByte
void FileWriteByte(int file, int byte)

Documentation

Pass a handle to a file that is opened in write mode, and an integer to be written. The byte will be written at the current position within the file, over any data that was previously there, and position will move to the next byte. As only one byte of the four that make up a verge integer is being written, any numbers bigger than 255 or less than 0 will NOT be written correctly. Use FileWriteQuad() unless sure the number being written will remain within these bounds.

Verge is effectivly only writing the 8 least significant bits of the passed integer, so performing a (integer & 255) operation before writing. Numbers outside the range of 0 to 255 will be written as another number with the range, depending on the value of the least significant byte.

Example Usage

int file = FileOpen("datafile.txt", FILE_WRITE);
FileWriteByte(file, 97); // or $61 or 'a'
FileClose(file);
// Opens/Creats a file and writes one byte to it
// Opened in a hex editor gives '61' as value of the byte
// In a text editor it gives the ascii 'a'

int file = FileOpen("datafile.txt", FILE_WRITE);
FileWriteByte(file, 0 - 2);
FileClose(file);
// Negative numbers are not stored properly
// Opened in a hex editor gives 'fe' as value of the byte
// -2 in binary: 11111111111111111111111111111110
// Least significant byte: 11111110
// Decimal: 254
Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.