file_bin_write_word

Downloadfile_bin_write_word(file,size,bigend,value)   Writes an integer word of the given size to a binary file in big-endian or little-endian format.
/*
**  Usage:
**      file_bin_write_word(file,size,bigend,value)
**
**  Arguments:
**      file        file id of an open binary file
**      size        size of the word in bytes
**      bigend      set to TRUE to use big-endian byte order (MSB first),
**                  or FALSE to use little-endian byte order (LSB first)
**      value       integer value to write to the file
**
**  Returns:
**      nothing
**
**  GMLscripts.com
*/

{
    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]);
}

Click if you've used this script[Please Login]
Projects: 8

 Contributors: Leif902, xot


comments powered by Disqus