ON UNDEFINEDFILE PL/1 怎么使用
时间: 2023-07-16 12:15:32 浏览: 75
PL1入门级教材
5星 · 资源好评率100%
UNDEFINEDFILE is a PL/1 compiler option that specifies the action to be taken when a program attempts to read from a file that has not been opened or has been closed unexpectedly.
To use UNDEFINEDFILE in PL/1, you need to specify it as a compiler option when compiling your program. Here's an example:
```
/* PL/1 program to demonstrate UNDEFINEDFILE */
OPTIONS UNDEFINEDFILE(ERROR);
DCL MYFILE FILE RECORD INPUT;
DCL MYVAR CHAR(10);
OPEN MYFILE(FILENAME('myfile.txt'));
READ MYFILE INTO(MYVAR);
CLOSE MYFILE;
END;
```
In this example, we have specified the UNDEFINEDFILE option as ERROR, which means that the program will terminate with an error message if it attempts to read from a file that has not been opened or has been closed unexpectedly.
You can also specify UNDEFINEDFILE as WARNING or IGNORE. If you specify it as WARNING, the program will issue a warning message but will continue executing. If you specify it as IGNORE, the program will ignore the error and continue executing as if nothing happened.
Note that UNDEFINEDFILE is a compiler option and not a PL/1 statement. Therefore, you need to specify it separately from your program code.
阅读全文