Table of Contents

OSClose statement

Description

Close an operating system file that has been opened with an OSOpen statement.

Syntax

OSClose filevar

Parameters

The OSClose statement has the following parameter.

ParameterDescription
filevarThe variable to which the operating system file was assigned when it was opened with an OSOpen statement.




You must specifically close any file opened with OSOpen.|

Returns

After the execution of an OSClose statement, the Status() of the close is returned with one of the following codes:

ValueMeaning
0No error.
1Bad OS filename.
2Access denied by operating system.
3Disk or directory full.
4File does not exist.
5Unknown error.
6Attempt to write to a read-only file.

See Also

OSBRead, OSBWrite, OSDelete, OSOpen, OSRead, OSWrite

Example

/* This code reads an existing OS file and copies it in 100 character chunks to a new OS file */

Equ RECSIZE$ To 100

readOffset = 0

writeOffset = 0

 

filename = "c:\temp\my_data.txt"

newFileName = "c:\temp\my_new_data.txt"

 

oswrite "" To newFileName ; * create the new file

 

OSOpen filename To inputFileHandle then

  OSOpen newFileName To outputFileHandle Then

    Loop

      OSBRead data From inputFileHandle At readOffset length RECSIZE$

      error = status()

    Until data = NULL$

      readOffset += RECSIZE$

      OSBWrite data On outputFileHandle At writeOffset

      writeOffset += RECSIZE$

    Repeat

  end else

    error = status()

  end

End else

  error = status()

End

 

osclose inputFileHandle

osclose outputFileHandle