file_bin_open

This function will open the binary file with the indicated name. The mode indicates what can be done with the file:

When the file does not exist it is created, and the function returns the id of the file that must be used in the other functions. You can open multiple files at the same time (32 max), but don't forget to close them once you are finished with them.

In the case of an error, the function will return -1. However, in some cases where the file could not be loaded (like an invalid filename being passed), the function may still return a file ID, in which case the return value of the file closing function will be false.

WARNING This may not work as you expect due to GameMaker being sandboxed! Please see the section on The File System for more information.

NOTE These functions do not work when the target module is HTML5.

 

Syntax:

file_bin_open(fname, mode);

ArgumentTypeDescription
fnameStringThe name of the file to read from.
modeRealThe indicator of what can be done with the file.

 

Returns:

Binary File ID or -1

 

Example:

file = file_bin_open("myfile.bin", 2);

This would open a file from the same directory as the game, and assign its index to the variable "file".