home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / inout.def < prev    next >
Text File  |  1996-09-03  |  7KB  |  163 lines

  1. (***********************************************************************)
  2. (*                                                                     *)
  3. (*                Modula-2 Compiler InOut Library Module               *)
  4. (*                                                                     *)
  5. (*          High level input and output procedures for                 *)
  6. (*          characters, strings, integers and cardinals                *)
  7. (*          and allows redirection of I/O to/from files                *)
  8. (*                                                                     *)
  9. (*       original module : N. Wirth, PIM-2,  1982                      *)
  10. (*       modifications   : 29-JUN-89 import from UxFiles               *)
  11. (*                         pms 10 Jul 95 Added ReadLn (undocumented)   *)
  12. (*                                                                     *)
  13. (***********************************************************************)
  14.  
  15. FOREIGN DEFINITION MODULE InOut; 
  16.  
  17.     IMPORT IMPLEMENTATION FROM "inout.o & uxfiles.o";
  18.  
  19.     CONST 
  20.  
  21.            EOL = 12C;        (* End-of-line character *)
  22.  
  23.  
  24.         VAR
  25.  
  26.            Done : BOOLEAN ;  (* Status of some InOut procedure calls.
  27.                                 TRUE if the operation was successful,
  28.                                 FALSE otherwise. *)
  29.  
  30.            termCh : CHAR ;   (* Terminating character of some input
  31.                                  procedures. ReadString, ReadInt, ReadCard *)
  32.  
  33.         PROCEDURE OpenInput(Extension : ARRAY OF CHAR);
  34.     (* Precondition  : TRUE
  35.        Postcondition : The primary input stream is redefined to be the
  36.                external file name whose names has been supplied
  37.                by the user. If the name ends with a "." the string
  38.                Extension is appended to the end of it.
  39.                Done = TRUE if and only if the file is opened
  40.                successfully *)
  41.  
  42.         PROCEDURE OpenOutput(Extension : ARRAY OF CHAR);
  43.     (* Precondition  : TRUE
  44.        Postcondition : The primary output stream is redefined to be the
  45.                external file name whose names has been supplied
  46.                by the user. If the name ends with a "." the string
  47.                Extension is appended to the end of it.
  48.                Done = TRUE if and only if the file is opened
  49.                successfully *)
  50.  
  51.         PROCEDURE CloseInput;
  52.     (* Precondition  : TRUE
  53.        Postcondition : The primary input stream is redefined to be the 
  54.                            terminal keyboard and the previously used input
  55.                            stream is closed *)
  56.  
  57.         PROCEDURE CloseOutput;
  58.     (* Precondition  : TRUE
  59.        Postcondition : The primary output stream is redefined to be the 
  60.                            terminal keyboard and the previously used output
  61.                            stream is closed *)
  62.  
  63.  
  64.  
  65.         PROCEDURE Read(VAR c:CHAR);
  66.         (* Precondition  : TRUE
  67.            Postcondition : Done = FALSE if and only if the end of the primary
  68.                            input stream is reached, otherwise c is the next 
  69.                            character in the stream.  *)
  70.  
  71.  
  72.  
  73.         PROCEDURE ReadLn();
  74.         (* Precondition  : TRUE
  75.            Postcondition : Skips to the beginning of the next new line.
  76.                            Done = FALSE if and only if the end of the primary
  77.                            input stream is reached. *)
  78.  
  79.  
  80.  
  81.         PROCEDURE ReadString(VAR s: ARRAY OF CHAR);
  82.         (* Precondition  : TRUE
  83.            Postcondition : Inputs a character string from the primary input
  84.                            stream until any character less than or equal to 
  85.                            a blank is read. The variable termCh is set to the
  86.                            value of this terminating character. 
  87.                            The NUL character (0C) or the end of the array is
  88.                            used to mark the end of the string.
  89.                            Leading blanks and/or tabs are ignored. Excess 
  90.                            characters beyond the length of s are discarded. *)
  91.  
  92.  
  93.         PROCEDURE ReadCard(VAR n: CARDINAL);
  94.         (* Precondition  : TRUE
  95.            Postcondition : Done = TRUE if and only if the next sequence of 
  96.                            characters on the input stream represents a
  97.                            CARDINAL value. The variable termCh is set to the
  98.                            value of the character that terminates this 
  99.                            sequence.  *)
  100.  
  101.  
  102.         PROCEDURE ReadInt(VAR i : INTEGER);
  103.         (* Precondition  : TRUE
  104.            Postcondition : Done = TRUE if and only if the next sequence of 
  105.                            characters on the input stream represents a
  106.                            INTEGER value. The variable termCh is set to the
  107.                            value of the character that terminates this 
  108.                            sequence.  *)
  109.  
  110.   
  111.         PROCEDURE Write(c:CHAR);
  112.         (* Precondition  : c is defined.
  113.            Postcondition : The character representation corresponding to the
  114.                            value of c is written to the output stream.  *)
  115.  
  116.  
  117.         PROCEDURE WriteLn;
  118.         (* Precondition  : TRUE
  119.            Postcondition : Equivalent to Write(EOL).  *)
  120.  
  121.  
  122.         PROCEDURE WriteString(s : ARRAY OF CHAR);
  123.         (* Precondition  : s is defined.
  124.            Postcondition : Outputs a string of characters until a NUL character
  125.                            or the end of the array is encountered.  *)
  126.  
  127.  
  128.         PROCEDURE WriteCard(n: CARDINAL; w: CARDINAL);
  129.         (* Precondition  : n and w are defined.
  130.            Postcondition : The value of n is written to the output stream
  131.                            occupying at least w character positions. Leading
  132.                            blanks fill out the space if it is not all required.
  133.                            The decimal number system is used.  *)
  134.  
  135.  
  136.  
  137.         PROCEDURE WriteInt(i: INTEGER; w: CARDINAL);
  138.         (* Precondition  : i and w are defined.
  139.            Postcondition : The value of i is written to the output stream
  140.                            occupying at least w character positions. Leading
  141.                            blanks fill out the space if it is not all required.
  142.                            The decimal number system is used and a sign is 
  143.                            displayed only for negative numbers.  *)
  144.  
  145.  
  146.         PROCEDURE WriteOct(n: CARDINAL; w: CARDINAL);
  147.         (* Precondition  : n and w are defined.
  148.            Postcondition : The value of n is written to the output stream
  149.                            occupying at least w character positions. Leading
  150.                            blanks fill out the space if it is not all required.
  151.                            The octal number system is used.  *)
  152.  
  153.  
  154.         PROCEDURE WriteHex(n: CARDINAL; w: CARDINAL);
  155.         (* Precondition  : n and w are defined.
  156.            Postcondition : The value of n is written to the output stream
  157.                            occupying at least w character positions. Leading
  158.                            blanks fill out the space if it is not all required.
  159.                            The hexadecimal number system is used.  *)
  160.  
  161.  
  162. END InOut.
  163.