GLBasic User Manual

Main sections

GENFILE()

id% = GENFILE()



This command returns an index that can be used to open a resource with OPENFILE without overwriting already loaded data.

If no more memory is available, -1 will be returned.

The obvious advantage of this approach is that you can write libraries that fit seamlessly into existing projects without interfering with the existing code.
If using these commands to allocate indicies in any part of your code, you should use them throughout your whole program.


The example here:
test$ = "test.bin"
OPENFILE(1, test$, FALSE)

WRITEBYTE 1, 42


Can be written as:
GLOBAL gFileTest
gFileTest = GENFILE()
test$ = "test.bin"
OPENFILE(gFileTest, test$, FALSE)

WRITEBYTE gFileTest, 42

See also...