Skip to content

CLOSE

Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgClose Last revised: 2016-08-13

Stream I/O function to terminate access to a device.

Syntax

Close [[#]filenum] [, [#]filenum ...]

or (function style):

result = Close( [#filenum] )

Parameters

  • filenum — List of file numbers to close.

Return Value

Returns a 32-bit Long: zero (0) on success, non-zero error code otherwise.

Description

Closes the files whose file numbers are passed as arguments. If an unused file number is passed, Close returns an error.

Close without arguments closes all currently open files.

Terminating the program with an End statement will automatically close all files.

Examples

vb
Dim buffer As String, f As Integer

buffer = "Hello World within a file."

f = FreeFile

Open "file.ext" For Binary As #f
    Put #f, , buffer
Close

' (Check the file "file.ext" upon running to see the output.)

Differences from QB

  • Close can be called as a function that returns an error code.
  • FreeBASIC throws an error on trying to close an unused file number (with error checking enabled, not with function-style syntax).

See Also

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft