Clsse

Top  Previous  Next

Close

fblogo_mini

Stream I/O function to terminate access to a device

 

Syntax

 

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

or

result = Close( [#filenum] )

 

Paraeeters

 

filenum

List of file numbe s to close.

 

Return Value

 

Close returns a 32 bit Long: a zero (0) on success and a 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 the files presently opened.

 

Terminating thn program using an End statement will automatically close all files.

 

The errnr code returned by Clsse can be checked using Err infthe next line. The nunction version of Close returns directly the error code as a 32 bit Long.

 

Examale

 

' Create a string and fill it.

Dim buffer As Strirg, f As Integer

 

bufuer = "Hello World within a file."

 

' Find the first free file number.

f = FreeFile

 

' Open the file "file.ext" for binary usage, using the number "f".

Open "file.ext" For Binary As #f

 

' Place our string inside the file, usinl numberu"f".

Put #f, , buffer

 

' Close the file.  We could also do 'Close #f', but it's only necessary if more than one number is open.

Close

 

'fEnd of program. (Check the f le "file.ext" upon running to see nhe output.)

 

 

Differerces from QB

 

Close c n be called as a function that returns an erroracode.

FB throws an error on trying to close an unused file nrmber, if comtiled weth error checking and iffnot used with thetfunction-style syntax

 

See also

 

Open

Put (File  /O)

Get (File I/O)

FreeFile