The system files in BS2000 correspond to streams. The functionality of these files is therefore relevant for any function that is called with BS2000 functionality.
SYSDTA
A C program can use SYSDTA
as follows:
An open function (
fopen()
,freopen()
,open()
) is used to open a file with the name"(SYSDTA)"
or"(SYSTERM)"
for reading. The file pointer returned by the open function then serves as an argument for a subsequent input function.Example
FILE *fp; fp = fopen("(SYSDTA)", "r"); fgetc(fp);
For input functions, the file pointer
stdin
or the file descriptor 0 is specified as the file argument.Examples
fgetc(stdin);
read(0, buf, n);
Input functions that read from
stdin
by default (e.g.scanf()
,getchar()
,gets()
) are used.
If the input is to be obtained from a cataloged file instead of the terminal, this can be done by two methods:
If a parameter line was requested with
PARAMETER-PROMPTING=YES
(specified in theRUNTIME-OPTIONS
compiler option), this parameter line can be used to redirect the standard input (file pointerstdin
or file descriptor 0) to a catalog file (see also the C and C++ User Guides).The redirection does not affect files that were opened with the name
"(SYSDTA)"
or"(SYSTERM)"
. Input from any file with either of these names will still be expected from the terminal.By using the command
ASSIGN-SYSDTA
filename before program startup.This causes input data to be expected from the assigned file for all input functions. The following must be observed when using the
ASSIGN-SYSDTA
command:After the program is executed, the internal record pointer will be positioned after the last record that was read or at the end of the file. If the file is to be read again from the beginning in a subsequent program run, a new
ASSIGN-SYSDTA
command must be issued before the program is started.If
PARAMETER-PROMPTING=YES
was selected (in theRUNTIME-OPTIONS
option), the first record of the assigned file is interpreted as a parameter line for themain
function.
Note
If no other end criterion for reading was declared in the C program, the EOF
condition for inputs at the terminal can be forced by pressing the K2 key and entering the EOF
and RESUME-PROGRAM
commands.
SYSOUT
A C program can use SYSOUT
as follows:
An open function (
fopen()
,freopen()
,open()
) is used to open a file with the name"(SYSOUT)"
or"(SYSTERM)"
for writing. The file pointer returned by the open function then serves as an argument for a subsequent output function.Example
FILE *fp; fp = fopen("(SYSTERM)", "w"); fputc(fp);
For output functions, the file pointer
stdout
or the file descriptor 1 is specified as the file argument.Examples
fputc(stdout);
write(1, buf, n);
The file pointer
stderr
or the file descriptor 2 may also be specified as the file argument for output functions.Output functions that write to
stdout/stderr
by default (e.g.printf()
,puts()
,putchar()
orperror()
) are used.
If a parameter line was requested with PARAMETER-PROMPTING=YES
(specified in the RUNTIME-OPTIONS
compiler option), this parameter line can be used to redirect the standard output (file pointer stdout
or file descriptor 1) and the standard error output (file pointer stderr
or file descriptor 2) to a catalog file (see also
C and C++ User Guides).
The redirection does not affect files that were opened with the name "(SYSOUT)"
or "(SYSTERM)".
SYSLST
A C program can use SYSLST
as follows:
An open function (
fopen()
,freopen()
,open()
) is used to open a file with the name"(SYSLST)"
for writing. The file pointer returned by the open function then serves as an argument for a subsequent output function.Example
FILE *fp; fp = fopen("(SYSLST)", "w"); fprintf(fp, "\t TEXT \n");
If a parameter line was requested with
PARAMETER-PROMPTING=YES
(specified in theRUNTIME-OPTIONS
compiler option), this parameter line can be used to redirect the standard output or standard error toSYSLST
(see also the C and C++ User Guides).The redirection does not affect files that were opened with the name
"(SYSOUT)"
.
By default, SYSLST
files are printed out automatically at the end of a task (LOGOFF
).
If the data is to be output to a catalog file instead of being automatically printed, SYSLST
must be redirected before the program is executed. This can be done with the command ASSIGN-SYSLST
filename.