File: InOut.mi

package info (click to toggle)
mocka 9905-2
  • links: PTS
  • area: non-free
  • in suites: potato, sarge, woody
  • size: 5,436 kB
  • ctags: 160
  • sloc: asm: 23,203; makefile: 124; sh: 102; ansic: 23
file content (145 lines) | stat: -rw-r--r-- 4,204 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
(******************************************************************************)
(* Copyright (c) 1988 by GMD Karlruhe, Germany				      *)
(* Gesellschaft fuer Mathematik und Datenverarbeitung			      *)
(* (German National Research Center for Computer Science)		      *)
(* Forschungsstelle fuer Programmstrukturen an Universitaet Karlsruhe	      *)
(* All rights reserved.							      *)
(******************************************************************************)

IMPLEMENTATION MODULE InOut;

  IMPORT TextIO;

  VAR
    StdIn, StdOut : TextIO.File;

  PROCEDURE Read
    (VAR x: CHAR);
  (* Read the next character from std input into 'x' *)
  BEGIN
    TextIO.GetChar (StdIn,x);
  END Read;

  PROCEDURE ReadString
    (VAR x: ARRAY OF CHAR);
  (* Read the next string from std input into 'x' *)
  (* Leading blanks are ignored *)
  (* Input is terminated by any character <= ' ' *)
  BEGIN
    TextIO.GetString (StdIn,x);
  END ReadString;

  PROCEDURE ReadCard
    (VAR x: CARDINAL);
  (* Read the next string from std input and convert it to cardinal 'x' *)
  BEGIN
    TextIO.GetCard (StdIn,x);
  END ReadCard;

  PROCEDURE ReadInt
    (VAR x: INTEGER);
  (* Read the next string from std input and convert it to integer 'x' *)
  BEGIN
    TextIO.GetInt (StdIn,x);
  END ReadInt;

  PROCEDURE ReadReal
    (VAR x: REAL);
  (* Read the next string from std input and convert it to real 'x' *)
  BEGIN
    TextIO.GetReal (StdIn,x);
  END ReadReal;

  PROCEDURE ReadLongReal
    (VAR x: LONGREAL);
  (* Read the next string from std input and convert it to long real 'x' *)
  BEGIN
    TextIO.GetLongReal (StdIn,x);
  END ReadLongReal;

  PROCEDURE Write (x: CHAR);
  (* Write character 'x' onto std output *)
  BEGIN
    TextIO.PutChar (StdOut,x);
  END Write;

  PROCEDURE WriteString (VAR x: ARRAY OF CHAR);
  (* Write the string 'x' onto std output *)
  BEGIN
    TextIO.PutString (StdOut,x);
  END WriteString;

  PROCEDURE WriteCard (x, n: CARDINAL);
  (* Convert the cardinal 'x' into decimal representation and *)
  (* write it onto std output. Field width is at least 'n'.   *)
  BEGIN
    TextIO.PutCard (StdOut,x,n);
  END WriteCard;

  PROCEDURE WriteOct (x, n: CARDINAL);
  (* Convert the cardinal 'x' into octal representation and *)
  (* write it onto std output. Field width is at least 'n'. *)
  BEGIN
    TextIO.PutOct (StdOut,x,n);
  END WriteOct;

  PROCEDURE WriteHex (x, n: CARDINAL);
  (* Convert the cardinal 'x' into hexadecimal representation   *)
  (* and write it onto std output. Field width is at least 'n'. *)
  BEGIN
    TextIO.PutHex (StdOut,x,n);
  END WriteHex;

  PROCEDURE WriteInt (x: INTEGER; n: CARDINAL);
  (* Convert the integer 'x' into decimal representation and *)
  (* write it onto std output. Field width is at least 'n'.  *)
  BEGIN
    TextIO.PutInt (StdOut,x,n);
  END WriteInt;

  PROCEDURE WriteReal (x: REAL; n: CARDINAL; k: INTEGER);
  (* Convert the real 'x' into external representation and  *)
  (* write it onto std output. Field width is at least 'n'. *)
  (* If k > 0 use k decimal places.                         *)
  (* If k = 0 write x as integer.                           *)
  (* If k < 0 use scientific notation.                      *)
  BEGIN
    TextIO.PutReal (StdOut,x,n,k);
  END WriteReal;

  PROCEDURE WriteLongReal (x: LONGREAL; n: CARDINAL; k: INTEGER);
  (* Convert longreal 'x' into external representation and  *)
  (* write it onto std output. Field width is at least 'n'. *)
  (* If k > 0 use k decimal places.                         *)
  (* If k = 0 write x as integer.                           *)
  (* If k < 0 use scientific notation.                      *)
  BEGIN
    TextIO.PutLongReal (StdOut,x,n,k);
  END WriteLongReal;

  PROCEDURE WriteLn;
  (* Write the end of line character onto std output *)
  BEGIN
     TextIO.PutLn (StdOut);
     TextIO.PutBf (StdOut);
  END WriteLn;

  PROCEDURE WriteBf;
  BEGIN
     TextIO.PutBf(StdOut);
  END WriteBf;

  PROCEDURE Done () : BOOLEAN;
  BEGIN
     RETURN TextIO.Done ()
  END Done;

  PROCEDURE EOF () : BOOLEAN;
  BEGIN
     RETURN TextIO.EOF (StdIn)
  END EOF;

BEGIN
  TextIO.OpenInput  (StdIn,  "-");
  TextIO.OpenOutput (StdOut, "-");
END InOut.