mk90.basic.statements

Statement OPEN

Open the program’s one regular data file.

Syntax

OPEN "path",INPUT
OPEN "path",OUTPUT,length

Parameters

ParameterMeaning
pathLiteral MKS2 pathname; relative to the shell directory in which the program runs.
INPUT / OUTPUTBinary read or exact-length replacement; no AS clause.
lengthOutput length expression interpreted as unsigned, 0–64256, subject to volume space.

Behavior

The executable already holds one of the two file handles, leaving one data handle. Close it before opening another file. INPUT requires an existing regular file; OUTPUT creates or replaces using a new extent.

OUTPUT does not publish until a successful CLOSE or END after exactly the declared length has been supplied. Every sector is verified. Failure preserves the former destination.

The pathname is a literal, not a string expression. File names and components preserve case. Controller and filesystem errors use the ordinary OS status codes.

Example

10 OPEN "bytes",OUTPUT,2
20 PUT 65
30 PUT 66
40 CLOSE
50 END

Limits and diagnostics

This comma-based syntax is an MBC-16 extension. No handles or #file numbers in BASIC, simultaneous data files, append, seek, text-file INPUT#/PRINT#, /dev/null or /dev/console.

Status-code reference.

See also

GET · PUT · CLOSE · END · Language syntax