You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

file_bin_write_word

Writes a binary word of a given byte-size to an open binary file.

fid = file_bin_open("test.dat", 1);
word = 123456789;
file_bin_write_word(fid, 4, true, word));
file_bin_write_word(fid, 4, false, word));
file_bin_close(fid);
//  test.dat contents: 07 5B CD 15 15 CD 5B 07
file_bin_write_word(file,size,bigend,value)
Writes a binary word of a given byte-size to an open binary file.
COPY/// file_bin_write_word(file,size,bigend,value)
//
//  Writes a binary word of a given byte-size to an open binary file.
//
//      file        file id of an open binary file, real
//      size        size of the word in bytes, real
//      bigend      true to use big-endian byte order (MSB first), bool
//      value       integer value to write, real
//
/// GMLscripts.com/license
{
    var file,size,bigend,value,i,b;
    file = argument0;
    size = argument1;
    bigend = argument2;
    value = argument3;
    for (i=0; i<size; i+=1) {
        b[i] = value & 255;
        value = value >> 8;
    }
    if (bigend) for (i=size-1; i>=0; i-=1) file_bin_write_byte(file,b[i]);
    else for (i=0; i<size; i+=1) file_bin_write_byte(file,b[i]);
    return 0;
}

Contributors: Leif902, xot

GitHub: View · Commits · Blame · Raw