basic.%fopen C Function/BASIC Program

basic.%fopen

Command basic.%fopen C Function/BASIC Program
Applicable release versions: AP/Unix
Category BASIC Program (486)
Description opens the Unix file designated by "string" and associates a stream with it.

"type" is a character string having one of the following values:

"r" Opens for reading only.

"w" Truncates or creates for writing only.

"a" Append; opens for writing at the end of file or creates for writing.

"r+" Opens for update.

"w+" Truncates or creates for update.

"a+" Append; opens for writing at the end of file or creates for update.

The stream is returned as a pointer to a character or 0 if an error occurred. System(0) contains the error number.

Streams are not automatically closed at program termination.
Syntax stream=(char*)%fopen(string, type)
Options
Example
stream=(char*)%fopen('/usr/pick/fname',"w+")
if stream=0 then 
  crt 'Cannot open stream. errno=':system(0)
end
Purpose
Related basic.cfunc
basic.%fdopen
basic.%freopen
basic.cfunction
basic.%fclose
basic.%fgetc
basic.%fgets
basic.%fprintf
basic.%fputc