Operation Details

The FILENUM library maintains a list of free and occupied file numbers. This is kept in the filenum_in_use array. You can see this array's contents under the debugger. To get a free file number, call filenum_get() and it will return a file number, which will now be marked as used. The function will return 255 if there are no free file numbers left, so watch out for this number!

When calling filenum_get(), you can supply a meaningful short name of the caller. For example, if the file number is to be used for accessing the log file, set the signature to "LOG". The filenum_user_signature array keeps the signatures left by filenum_get() callers. Observing this array's contents under the debugger will provide a clear picture of who is using which file number. The signature of free file numbers is "-". Note that FILENUM_MAX_SIGNATURE_LEN defines maximum signature length and the default value is 0. Set this to anything above 0 to be able to observe the signatures. You can set it back to 0 when the debugging process is over.

Another way to observe the operation of the library in the debug mode is by adding #define FILENUM_DEBUG_PRINT 1 to the defines section of the global.tbh file of your project. A wealth of status information will be printed in the console pane as the FILENUM library operates.

To release the file niumber, call filenum_release(). This will mark the file number as free and the next caller of the filenum_get() will have a chance to reuse this file number.

Filenum_who_uses() returns a signature left by the specified file number's user. This function doesn't have to be used and exists only for convenience.