Listing: 1 (* Release 3.10 *) 2 (*-------------------------------------------------------------------------* 3 * * 4 * INOUT.MOD - input/output (core library) * 5 * * 6 * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. * 7 * All Rights Reserved * 8 * * 9 *--------------------------------------------------------------------------*) 10 11 (*$V-*) 12 IMPLEMENTATION MODULE InOut ; 13 IMPORT FIO,Str,Terminal,ASCII ; 14 VAR 15 InputFile, 16 OutputFile : CARDINAL ; 17 18 PROCEDURE AddExt ( VAR fn : ARRAY OF CHAR ; ext : ARRAY OF CHAR ) ; ***** ^ not supported yet ***** ^ not supported yet 19 VAR 20 i,p : CARDINAL ; 21 BEGIN 22 p := Str.Length(fn) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 23 i := 1 ; 24 LOOP 25 IF (i>p)OR(i=5)OR(fn[p-i] = '\') THEN ***** ^ not supported yet ***** ^ not supported yet 26 Str.Append(fn,'.'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 27 Str.Append(fn,ext); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 28 RETURN ; 29 END ; 30 IF fn[p-i]='.' THEN RETURN END ; ***** ^ not supported yet ***** ^ not supported yet 31 INC(i) ; ***** ^ undeclared identifier ***** ^ not supported yet 32 END ; 33 END AddExt ; ***** ^ not supported yet 34 35 PROCEDURE OpenInput ( defext : ARRAY OF CHAR ) ; ***** ^ not supported yet 36 VAR 37 fn : FIO.PathStr ; ***** ^ not supported yet 38 BEGIN 39 CloseInput ; ***** ^ undeclared identifier 40 Terminal.WriteString('IN>'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 41 Terminal.ReadString(fn) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 42 Terminal.WriteLn ; ***** ^ not supported yet ***** ^ not supported yet 43 IF fn[0]=0C THEN RETURN END ; ***** ^ not supported yet ***** ^ not supported yet 44 AddExt(fn,defext) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 45 InputFile := FIO.Open(fn) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 46 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 47 IF NOT Done THEN ***** ^ undeclared identifier 48 InputFile := FIO.StandardInput ; ***** ^ not supported yet ***** ^ not supported yet 49 END ; 50 END OpenInput ; ***** ^ not supported yet 51 52 PROCEDURE OpenOutput ( defext : ARRAY OF CHAR ) ; ***** ^ not supported yet 53 VAR 54 fn : FIO.PathStr ; ***** ^ not supported yet 55 BEGIN 56 CloseOutput ; ***** ^ undeclared identifier 57 Terminal.WriteString('OUT>'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 58 Terminal.ReadString(fn) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 59 Terminal.WriteLn ; ***** ^ not supported yet ***** ^ not supported yet 60 IF fn[0]=0C THEN RETURN END ; ***** ^ not supported yet ***** ^ not supported yet 61 AddExt(fn,defext) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 62 OutputFile := FIO.Create(fn) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 63 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 64 IF NOT Done THEN ***** ^ undeclared identifier 65 OutputFile := FIO.StandardOutput ; ***** ^ not supported yet ***** ^ not supported yet 66 END ; 67 END OpenOutput ; ***** ^ not supported yet 68 69 PROCEDURE CloseInput ; 70 BEGIN 71 IF InputFile<>FIO.StandardInput THEN ***** ^ not supported yet ***** ^ not supported yet 72 FIO.Close(InputFile) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 73 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 74 InputFile := FIO.StandardInput ; ***** ^ not supported yet ***** ^ not supported yet 75 ELSE 76 Done := TRUE ; ***** ^ undeclared identifier 77 END ; 78 END CloseInput ; ***** ^ not supported yet 79 80 PROCEDURE CloseOutput ; 81 BEGIN 82 IF OutputFile<>FIO.StandardOutput THEN ***** ^ not supported yet ***** ^ not supported yet 83 FIO.Close(OutputFile) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 84 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 85 OutputFile := FIO.StandardOutput ; ***** ^ not supported yet ***** ^ not supported yet 86 ELSE 87 Done := TRUE ; ***** ^ undeclared identifier 88 END ; 89 END CloseOutput ; ***** ^ not supported yet 90 91 PROCEDURE Read ( VAR v : CHAR ) ; 92 VAR 93 b : BOOLEAN ; 94 BEGIN 95 REPEAT 96 IF InputFile=FIO.StandardInput THEN ***** ^ not supported yet ***** ^ not supported yet 97 Terminal.Read(v) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 98 Done := (v<>CHR(26)) ; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 99 ELSE 100 v := FIO.RdChar(InputFile) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 101 Done := (FIO.IOresult()=0)AND(v<>CHR(26)) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 102 END ; 103 UNTIL v<>ASCII.lf ; (* LF ignored *) ***** ^ not supported yet ***** ^ not supported yet 104 IF v=ASCII.cr THEN ***** ^ not supported yet ***** ^ not supported yet 105 v := EOL ; ***** ^ undeclared identifier 106 END ; 107 END Read ; ***** ^ not supported yet 108 109 PROCEDURE ReadString ( VAR v : ARRAY OF CHAR ) ; ***** ^ not supported yet 110 VAR 111 c : CHAR ; 112 line : ARRAY[0..255] OF CHAR ; ***** ^ not supported yet ***** ^ not supported yet 113 p : CARDINAL ; 114 BEGIN 115 v[0] := 0C ; ***** ^ not supported yet ***** ^ not supported yet 116 IF InputFile=FIO.StandardInput THEN ***** ^ not supported yet ***** ^ not supported yet 117 Terminal.ReadString(v) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 118 termCH := Terminal.termCH ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 119 Done := (termCH<>CHR(26)) ; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 120 ELSE 121 p := 0 ; 122 REPEAT Read(c) UNTIL (c<>' ') OR NOT Done ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 123 LOOP 124 IF NOT Done THEN EXIT END ; ***** ^ undeclared identifier 125 IF (c>' ') THEN 126 IF pCHR(26)) ; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 139 END ReadString ; ***** ^ not supported yet 140 141 PROCEDURE ReadCard ( VAR v : CARDINAL ) ; 142 VAR 143 r : LONGCARD ; ***** ^ undeclared identifier 144 line : ARRAY[0..79] OF CHAR ; ***** ^ not supported yet ***** ^ not supported yet 145 BEGIN 146 ReadString(line) ; ***** ^ not supported yet ***** ^ not supported yet 147 r := Str.StrToCard(line,10,Done) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 148 Done := Done AND (r<=MAX(CARDINAL)) ; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 149 v := CARDINAL(r) ; ***** ^ not supported yet 150 END ReadCard ; ***** ^ not supported yet 151 152 PROCEDURE ReadInt ( VAR v : INTEGER ) ; 153 VAR 154 r : LONGINT ; 155 line : ARRAY[0..79] OF CHAR ; ***** ^ not supported yet ***** ^ not supported yet 156 BEGIN 157 ReadString(line) ; ***** ^ not supported yet ***** ^ not supported yet 158 r := Str.StrToInt(line,10,Done) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 159 Done := Done AND (r>=MIN(INTEGER)) AND (r<=MAX(INTEGER)) ; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 160 v := INTEGER(r) ; ***** ^ not supported yet 161 END ReadInt ; ***** ^ not supported yet 162 163 164 165 PROCEDURE Write ( v : CHAR ) ; 166 BEGIN 167 IF OutputFile=FIO.StandardOutput THEN ***** ^ not supported yet ***** ^ not supported yet 168 IF v=EOL THEN Terminal.WriteLn() ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 169 ELSE Terminal.Write(v) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 170 END ; 171 Done := TRUE ; ***** ^ undeclared identifier 172 ELSE 173 IF v=EOL THEN FIO.WrLn(OutputFile) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 174 ELSE FIO.WrChar(OutputFile,v) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 175 END ; 176 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 177 END ; 178 END Write ; ***** ^ not supported yet 179 180 PROCEDURE WriteLn ; 181 BEGIN 182 Write(EOL) ; ***** ^ not supported yet ***** ^ undeclared identifier 183 END WriteLn ; ***** ^ not supported yet 184 185 PROCEDURE WriteString ( v : ARRAY OF CHAR ) ; ***** ^ not supported yet 186 VAR 187 buff : ARRAY[0..256] OF CHAR ; ***** ^ not supported yet ***** ^ not supported yet 188 i,j : CARDINAL ; 189 c : CHAR ; 190 191 PROCEDURE OutBuff ; 192 BEGIN 193 IF Done THEN ***** ^ undeclared identifier 194 buff[j] := CHR(0) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 195 IF OutputFile=FIO.StandardOutput THEN ***** ^ not supported yet ***** ^ not supported yet 196 Terminal.WriteString(buff) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 197 Done := TRUE ; ***** ^ undeclared identifier 198 ELSE 199 FIO.WrStr(OutputFile,buff) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 200 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 201 END ; 202 j := 0 ; 203 END ; 204 END OutBuff; ***** ^ not supported yet 205 206 BEGIN 207 i := 0 ; j := 0 ; 208 Done := TRUE ; ***** ^ undeclared identifier 209 LOOP 210 IF i>HIGH(v) THEN OutBuff ; RETURN END ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 211 c := v[i] ; INC(i) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 212 IF c=CHR(0) THEN OutBuff ; RETURN END ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 213 IF c=EOL THEN OutBuff ; WriteLn ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 214 ELSE 215 buff[j] := c ; INC(j) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 216 IF j=SIZE(buff)-1 THEN OutBuff END ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 217 END ; 218 IF NOT Done THEN RETURN END ; ***** ^ undeclared identifier 219 END ; 220 END WriteString ; ***** ^ not supported yet 221 222 PROCEDURE WriteCard ( v : CARDINAL ; w : CARDINAL ) ; 223 BEGIN 224 FIO.WrCard(OutputFile,v,INTEGER(w)) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 225 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 226 END WriteCard ; ***** ^ not supported yet 227 228 PROCEDURE WriteInt ( v : INTEGER ; w : CARDINAL ) ; 229 BEGIN 230 FIO.WrInt(OutputFile,v,INTEGER(w)) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 231 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 232 END WriteInt ; ***** ^ not supported yet 233 234 PROCEDURE WriteOct ( v : CARDINAL ; w : CARDINAL ) ; 235 VAR s : ARRAY[0..80] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 236 BEGIN 237 Str.CardToStr( VAL( LONGCARD,v ),s,8,Done ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 238 IF Done THEN ***** ^ undeclared identifier 239 FIO.WrStrAdj(OutputFile,s,INTEGER(w) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 240 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 241 END; 242 END WriteOct ; ***** ^ not supported yet 243 244 PROCEDURE WriteHex ( v : CARDINAL ; w : CARDINAL ) ; 245 BEGIN 246 FIO.WrHex(OutputFile,v,INTEGER(w)) ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 247 Done := (FIO.IOresult()=0) ; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 248 END WriteHex ; ***** ^ not supported yet 249 250 BEGIN 251 Done := TRUE ; ***** ^ undeclared identifier 252 termCH := CHR(0) ; ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 253 InputFile := FIO.StandardInput ; ***** ^ not supported yet ***** ^ not supported yet 254 OutputFile := FIO.StandardOutput ; ***** ^ not supported yet ***** ^ not supported yet 255 FIO.IOcheck := FALSE ; ***** ^ not supported yet ***** ^ not supported yet 256 END InOut. ***** ^ not supported yet 325 errors