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"/BS2/(SYSDTA)"or"/BS2/(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("/BS2/(SYSDTA)", "r"); fgetc(fp);For input functions, the file pointer
stdinor the file descriptor 0 is specified as the file argument.Examples
fgetc(stdin);read(0, buf, n);Input functions that read from
stdinby 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-OPTIONScompiler option), this parameter line can be used to redirect the standard input (file pointerstdinor 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
"/BS2/(SYSDTA)"or"/BS2/(SYSTERM)". Input from any file with either of these names will still be expected from the terminal.By using the command
ASSIGN-SYSDTAfilename 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-SYSDTAcommand: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-SYSDTAcommand must be issued before the program is started.If
PARAMETER-PROMPTING=YESwas selected (in theRUNTIME-OPTIONSoption), the first record of the assigned file is interpreted as a parameter line for themainfunction.
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"/BS2/(SYSOUT)"or"/BS2/(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("/BS2/(SYSTERM)", "w"); fputc(fp);For output functions, the file pointer
stdoutor the file descriptor 1 is specified as the file argument.Examples
fputc(stdout);write(1, buf, n);The file pointer
stderror the file descriptor 2 may also be specified as the file argument for output functions.Output functions that write to
stdout/stderrby 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 "/BS2/(SYSOUT)" or "/BS2/(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"/BS2/(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("/BS2/(SYSLST)", "w"); fprintf(fp, "\t TEXT \n");If a parameter line was requested with
PARAMETER-PROMPTING=YES(specified in theRUNTIME-OPTIONScompiler 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
"/BS2/(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.