Listing: 1 2 MODULE prog7; 3 (* Sorts lines of a file into order, deleting duplicates *) 4 IMPORT IO, FIO, Lib, Storage, Str; 5 6 TYPE 7 StringType = ARRAY [0..255] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 8 StringPointerType = POINTER TO StringType; ***** ^ not supported yet 9 VAR 10 p : ARRAY [1..10000] OF StringPointerType; ***** ^ not supported yet ***** ^ not supported yet 11 12 PROCEDURE Less(i,j:CARDINAL):BOOLEAN; 13 BEGIN 14 RETURN Str.Compare(p[i]^, p[j]^) < 0 ; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 15 END Less; ***** ^ not supported yet 16 17 PROCEDURE Swap(i,j:CARDINAL); 18 VAR tmp:StringPointerType; ***** ^ not supported yet 19 BEGIN 20 tmp := p[i]; p[i] := p[j]; p[j] := tmp; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 21 END Swap; ***** ^ not supported yet 22 23 VAR s: StringType; ***** ^ not supported yet 24 len:CARDINAL; 25 i,n:CARDINAL; 26 InFile,OutFile:FIO.File; ***** ^ not supported yet 27 buffer:ARRAY [1..512+FIO.BufferOverhead] OF BYTE; ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 28 BEGIN 29 (* check parameters *) 30 IF Lib.ParamCount() <> 2 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 31 IO.WrStr('Try again : prog7 input-file output-file'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 32 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 33 HALT; ***** ^ undeclared identifier 34 END; 35 36 (* read file in *) 37 Lib.ParamStr(s, 1); InFile := FIO.Open(s); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 38 FIO.AssignBuffer(InFile, buffer); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 39 n := 0; 40 LOOP 41 FIO.RdStr(InFile, s); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 42 IF FIO.EOF THEN ***** ^ not supported yet ***** ^ not supported yet 43 EXIT; 44 END; 45 IF n = HIGH(p) THEN ***** ^ undeclared identifier ***** ^ not supported yet 46 IO.WrStr('Too many lines!'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 47 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 48 EXIT; 49 END; 50 INC(n); ***** ^ undeclared identifier ***** ^ not supported yet 51 len := Str.Length(s); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 52 Storage.ALLOCATE(p[n], len + 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 53 Lib.Move(ADR(s), ADR(p[n]^), len + 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 54 END; 55 56 FIO.Close(InFile); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 57 58 (* sort file in memory *) 59 Lib.HSort(n, Less, Swap); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 60 61 (* write file out *) 62 Lib.ParamStr(s, 2); OutFile := FIO.Create(s); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 63 FIO.AssignBuffer(OutFile, buffer); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 64 FOR i := 1 TO n DO 65 IF (i = 1) OR (Str.Compare(p[i]^, p[i-1]^) <> 0) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 66 FIO.WrStr(OutFile, p[i]^); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 67 FIO.WrLn(OutFile); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 68 END; 69 END; 70 FIO.Close(OutFile); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 71 72 END prog7. 73 74 117 errors