OSOpen statement

Opens an operating system file for use with OSBRead and OSBWrite statements.

OSOpen file To filevar Then Else statements

The OSOpen statement has the following parameters.

ParameterDescription
FileThe name of the operating system file (including path, filename, and extension) to be opened.
filevarIdentifies the variable to which the file is assigned.
ThenUsed to define a clause of statements to be executed when the OSOpen statement is successful.
ElseExecuted if the OSOpen is unsuccessful.

After processing, you must close the file, with OSClose.

Because the other operating system file statements, OSRead and OSWrite, read or write entire files into OpenInsight variables, they do not have to be opened (or closed).

After the execution of an OSOpen statement, the Status() of the open 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.
/* 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
  • guides/programming/programmers_reference_manual/osopen.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1