FileClose
This reference collection includes Vector documentation reproduced with permission. Snippets may require configuration-specific symbols and are not all standalone programs. Sources and validation limits.
Contract
long fileClose(dword fileHandle);
This closes the file identified by an opened numeric handle. The documented return is 1 on success and 0 on error. The File class has a corresponding Close method for its own object lifecycle.
Give one operation responsibility for the handle
A small importer or exporter is easiest to audit when one operation owns opening, use and closing. Other helpers can process records without independently closing the same handle. After a confirmed successful close, clear the application's handle variable so a later event cannot mistake the old value for an open file.
Do not call close on 0 after an unsuccessful open. Do not overwrite an existing open handle with the result of another open. Do not assume that a numeric handle remains valid after its file has been closed.
| Exit path | Required application behavior |
|---|---|
| Open failed | Report the open failure; no valid handle to close |
| Normal completion | Close once, check the result, then report completion |
| Invalid input or failed write | Preserve the original failure, attempt close, and report cleanup failure separately if present |
| User abort or measurement shutdown | Cancel further work on the handle and route cleanup through the same owner |
Closing does not repair failed data processing
Consider an export where the second write fails but close returns 1. Reporting only the close result would falsely declare the export successful. Keep a separate operation-success flag or failure record; closing releases the resource, while the earlier failure determines whether the dataset may be used.
If close itself returns 0, do not declare that resources were released or continue using the handle as though nothing happened. Stop further use by that operation and follow diagnostics for the installed version. This reference does not define a universally safe retry policy after a close error.
A focused verification sequence
With a disposable output, test a normal run and an application-level rejection halfway through processing. Instrument opening and cleanup so each successful open has one cleanup attempt. Repeat the operation without restarting the measurement and verify that old handle state is not reused. Inspect the output after closing; the count and content must match the claimed completion state.
These checks establish application lifecycle behavior; they do not claim storage durability or recovery from a power loss. Follow the complete file I/O walkthrough for content, path and record-boundary tests. The function contract comes from the authorized Vector reference; the lifecycle analysis is this site's commentary. See sources and limits.