📄 inout.h
字号:
// DEFINITION MODULE InOut;
/* NW 20.6.82 */
/* RA 23 JAN 1990, Comments Revised. */
#pragma InOut
#include <SYSTEM.h>
/* --------------------------------------------------------
This module provides the ability to read and write most
of the basic types present in Modula-2. In some cases,
the ability to write a TYPE in more than one format
is provided.
This module also provides the ability to open a file
to be read from, open a file to be written to, and close
each of those kinds of files.
-------------------------------------------------------- */
const char EOL = '\n';
/* This defines the ASCII character with decimal value 36,
as the End of Line marker */
boolean Done; /* Variable which can be read to obtain status from
many of the services provided in this module. */
char termCH; /* terminating character in ReadInt, ReadCard */
void OpenInput(char defext[]);
/* request a file name interactively and open that filename
with the extension specified by defext appended.
Hitting ENTER, opens standard input.
After the procedure completes, Done is TRUE only if a file
was successfully opened, and FALSE if standard input was opened.
Once opened, all subsequent input comes from this file
until it is closed.
*/
/* For BOTH OpenInput/OpenOutput, if the string defext contains a '.',
it is assumed to denote a filename that is to be opened. */
void OpenOutput(char defext[]);
/* request a file name interactively and open that filename
with the extension specified by defext appended.
After the procedure completes, Done is TRUE if the file
was successfully opened, and FALSE otherwise.
Once opened, all subsequent output is written on this file
until it is closed.
*/
void CloseInput();
/* closes input file currently open; returns input to terminal */
void CloseOutput();
/* closes output file currently open; returns output to terminal */
void Read(char &ch);
/* Read a single character from the current input.
Done := NOT in.eof */
void ReadString(char &s[]);
/* read a string from the current input.
Syntax of a String:
a sequence of characters not containing blanks or control characters;
leading blanks and newlines are ignored.
Input is terminated by any character <= " ";
which character is assigned to termCH.
DEL or BS is used for backspacing
when input is coming from a terminal
*/
void ReadInt(int &x);
/* read INTEGER x from the current input.
Syntax of an INTEGER:
integer = ["+"|"-"] digit {digit}.
Leading blanks and newlines are ignored.
Done is TRUE if the INTEGER was successfully read,
and FALSE otherwise.
*/
void ReadCard(unsigned int &x);
/* read CARDINAL x from the current input.
Syntax of a CARDINAL:
cardinal = digit {digit}.
Leading blanks and newlines are ignored.
Done is TRUE if the CARDINAL was successfully read,
and FALSE otherwise.
*/
void ReadWrd(WORD &w);
/* read a WORD from the current input.
The WORD type is defined in the SYSTEM module.
Done := NOT in.eof
*/
void Write(char ch);
/* write a single character to the current output. */
void WriteLn();
/* terminate the current output line. */
void WriteString(char s[]);
/* write a string, defined above, to the current output. */
void WriteInt(int x, unsigned int n);
/* write INTEGER number x to the current output as a string.
If n is greater than the number of digits needed,
blanks are added preceding the number such that the
string written is at least n characters long.
*/
void WriteCard(unsigned int x, unsigned int n);
/* write CARDINAL number x to the current output as a string.
If n is greater than the number of digits needed,
blanks are added preceding the number such that the
string written is at least n characters long.
*/
void WriteOct(unsigned int x, unsigned int n);
/* write CARDINAL number x to the current output as a string
in Octal format. If n is greater than the number of digits needed,
blanks are added preceding the number such that the string
written is at least n characters long.
*/
void WriteHex(unsigned int x, unsigned int n);
/* write the CARDINAL number x to the current output as a string
in Hexadecimal format. If n is greater than the number of
digits needed, blanks are added preceding the number such that
the string written is at least n characters long.
*/
void WriteWrd(WORD w);
/* write the number w to the current output as a string. */
void WriteLongInt(long x, unsigned int n);
/* write the LONGINT number x to the current output as a string.
If n is greater than the number of digits needed,
blanks are added preceding the number such that
the string written is at least n characters long.
*/
void WriteLongOct(long x, unsigned int n);
/* write the LONGINT number x to the current output as a string
in Octal format. If n is greater than the number of digits
needed, blanks are added preceding the number such that the
string written is at least n characters long.
*/
void WriteLongHex(long x, unsigned int n);
/* write the LONGINT number x to the current output as a string
in Hexadecimal format. If n is greater than the number of
digits needed, blanks are added preceding the number such that
the string written is at least n characters long.
*/
// END InOut.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -