home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / textinout.def < prev    next >
Text File  |  1996-08-29  |  6KB  |  120 lines

  1. (***********************************************************************)
  2. (*                                                                     *)
  3. (*              Modula-2 Compiler TextInOut Library Module             *)
  4. (*                                                                     *)
  5. (*          High level input and output procedures for                 *)
  6. (*          characters, strings, integers and cardinals                *)
  7. (*                                                                     *)
  8. (*       THIS MODULE PROVIDES THE SAME PROCEDURES AS InOut           *)
  9. (*     BUT USES NAMED FILES AS SOURCE AND DESTINATION               *)
  10. (*                                       *)
  11. (*       original module : N. Wirth, PIM-2,  1982 (InOut)              *)
  12. (*       modifications   :                            *)
  13. (*                                                                     *)
  14. (***********************************************************************)
  15.  
  16. FOREIGN DEFINITION MODULE TextInOut; 
  17.   IMPORT IMPLEMENTATION FROM "textinout.o & uxfiles.o";
  18.  
  19.   FROM UxFiles IMPORT File;
  20.  
  21.     CONST 
  22.            EOL = 12C;        (* End-of-line character *)
  23.  
  24.         VAR
  25.            Done : BOOLEAN ;  (* Status of some TextInOut procedure calls.
  26.                                 TRUE if the operation was successful,
  27.                                 FALSE otherwise. *)
  28.  
  29.            termCh : CHAR ;   (* Terminating character of some input
  30.                                  procedures. ReadString, ReadInt, ReadCard *)
  31.  
  32.  
  33.         PROCEDURE Read(inFile : File; VAR c:CHAR);
  34.         (* Precondition  : TRUE
  35.            Postcondition : Done = FALSE if and only if the end of the primary
  36.                            input stream is reached, otherwise c is the next 
  37.                            character in the stream.  *)
  38.  
  39.  
  40.         PROCEDURE ReadString(inFile : File; VAR s: ARRAY OF CHAR);
  41.         (* Precondition  : TRUE
  42.            Postcondition : Inputs a character string from the primary input
  43.                            stream until any character less than or equal to 
  44.                            a blank is read. The variable termCh is set to the
  45.                            value of this terminating character. 
  46.                            The NUL character (0C) or the end of the array is
  47.                            used to mark the end of the string.
  48.                            Leading blanks and/or tabs are ignored. Excess 
  49.                            characters beyond the length of s are discarded. *)
  50.  
  51.  
  52.         PROCEDURE ReadCard(inFile : File; VAR n: CARDINAL);
  53.         (* Precondition  : TRUE
  54.            Postcondition : Done = TRUE if and only if the next sequence of 
  55.                            characters on the input stream represents a
  56.                            CARDINAL value. The variable termCh is set to the
  57.                            value of the character that terminates this 
  58.                            sequence.  *)
  59.  
  60.  
  61.         PROCEDURE ReadInt(inFile : File; VAR i : INTEGER);
  62.         (* Precondition  : TRUE
  63.            Postcondition : Done = TRUE if and only if the next sequence of 
  64.                            characters on the input stream represents a
  65.                            INTEGER value. The variable termCh is set to the
  66.                            value of the character that terminates this 
  67.                            sequence.  *)
  68.  
  69.   
  70.         PROCEDURE Write(outFile : File; c:CHAR);
  71.         (* Precondition  : c is defined.
  72.            Postcondition : The character representation corresponding to the
  73.                            value of c is written to the output stream.  *)
  74.  
  75.  
  76.         PROCEDURE WriteLn(outFile : File); 
  77.         (* Precondition  : TRUE
  78.            Postcondition : Equivalent to Write(EOL).  *)
  79.  
  80.  
  81.         PROCEDURE WriteString(outFile : File; s : ARRAY OF CHAR);
  82.         (* Precondition  : s is defined.
  83.            Postcondition : Outputs a string of characters until a NUL character
  84.                            or the end of the array is encountered.  *)
  85.  
  86.  
  87.         PROCEDURE WriteCard(outFile : File; n: CARDINAL; w: CARDINAL);
  88.         (* Precondition  : n and w are defined.
  89.            Postcondition : The value of n is written to the output stream
  90.                            occupying at least w character positions. Leading
  91.                            blanks fill out the space if it is not all required.
  92.                            The decimal number system is used.  *)
  93.  
  94.  
  95.         PROCEDURE WriteInt(outFile : File; i: INTEGER; w: CARDINAL);
  96.         (* Precondition  : i and w are defined.
  97.            Postcondition : The value of i is written to the output stream
  98.                            occupying at least w character positions. Leading
  99.                            blanks fill out the space if it is not all required.
  100.                            The decimal number system is used and a sign is 
  101.                            displayed only for negative numbers.  *)
  102.  
  103.  
  104.         PROCEDURE WriteOct(outFile : File; n: CARDINAL; w: CARDINAL);
  105.         (* Precondition  : n and w are defined.
  106.            Postcondition : The value of n is written to the output stream
  107.                            occupying at least w character positions. Leading
  108.                            blanks fill out the space if it is not all required.
  109.                            The octal number system is used.  *)
  110.  
  111.  
  112.         PROCEDURE WriteHex(outFile : File; n: CARDINAL; w: CARDINAL);
  113.         (* Precondition  : n and w are defined.
  114.            Postcondition : The value of n is written to the output stream
  115.                            occupying at least w character positions. Leading
  116.                            blanks fill out the space if it is not all required.
  117.                            The hexadecimal number system is used.  *)
  118.  
  119. END TextInOut.
  120.