home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / TEST / LZW.M < prev    next >
Encoding:
Text File  |  1989-09-13  |  2.1 KB  |  3 lines

  1. ⓪ MODULE LZW;
  2. ⓪ 
  3. ⓪ FROM    InOut   IMPORT WriteString, WriteLn, WriteCard, Write, Read;
  4. ⓪ 
  5. ⓪ FROM Strings IMPORT Length;
  6. ⓪ 
  7. ⓪ FROM    SYSTEM  IMPORT ADDRESS, ADR, TSIZE;
  8. ⓪ 
  9. ⓪ FROM    Storage IMPORT ALLOCATE, DEALLOCATE;
  10. ⓪ 
  11. ⓪ FROM Compressions IMPORT GetInfo, Decode, Encode;
  12. ⓪ FROM RandomGen IMPORT RandomCard;
  13. ⓪ FROM SysUtil0 IMPORT VarEqual, ClearVar;
  14. ⓪ IMPORT Files, Binary, Directory;
  15. ⓪ 
  16. ⓪ VAR s0, s1, s2, s3: ARRAY [0..1999] OF CARDINAL; cl,l: LONGCARD;
  17. ⓪"s8: ARRAY [0..7] OF CHAR;
  18. ⓪"f:Files.File;
  19. ⓪"t: CARDINAL; ch: CHAR; ok: BOOLEAN;
  20. ⓪ BEGIN
  21. ⓪"Files.Open (f, 'G:\B', Files.readOnly);
  22. ⓪"Binary.ReadBytes (f, ADR (s0), SIZE(s0), l);
  23. ⓪"Files.Close (f);
  24. ⓪"WriteString ('source len: ');WriteCard (l, 0);
  25. ⓪"WriteLn;
  26. ⓪"s1:= s0;
  27. ⓪"Encode (0, ADR (s1), l, ADR (s2), SIZE (s2), cl);
  28. ⓪"WriteString ('code len:   ');WriteCard (cl, 0);
  29. ⓪"WriteLn;
  30. ⓪"s8:= 'MM2Comp';
  31. ⓪"(*
  32. ⓪"Files.Create (f, 'G:\A.LZW', Files.writeOnly, Files.replaceOld);
  33. ⓪"Binary.WriteBytes (f, ADR (s8), SIZE(s8));
  34. ⓪"Binary.WriteBytes (f, ADR (s2), cl);
  35. ⓪"Files.Close (f);
  36. ⓪"*)
  37. ⓪"Files.Open (f, 'G:\A', Files.readOnly);
  38. ⓪"Binary.ReadBytes (f, ADR (s8), SIZE(s8), l);
  39. ⓪"Binary.ReadBytes (f, ADR (s3), cl, l);
  40. ⓪"Files.Close (f);
  41. ⓪"GetInfo (ADR(s3), t, l);
  42. ⓪"ClearVar (s1);
  43. ⓪"Decode (ADR (s3), cl, ADR (s1), l, ok);
  44. ⓪"WriteString ('source len: ');WriteCard (l, 0); WriteCard (t, 4);
  45. ⓪"WriteLn;
  46. ⓪"IF NOT ok THEN
  47. ⓪$WriteString ('NOT ok')
  48. ⓪"END;
  49. ⓪"WriteLn;
  50. ⓪"IF VarEqual (s1, s0) THEN
  51. ⓪$WriteString ('OK')
  52. ⓪"ELSE
  53. ⓪$WriteString ('Error!')
  54. ⓪"END;
  55. ⓪"WriteLn;
  56. ⓪"Read(ch);
  57. ⓪ END LZW.
  58. ⓪ ə
  59. (* $FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$0000059F$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEAB4E0$FFEAB4E0$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEC9760$FFEAB4E0$FFEC9760$FFEC9760$FFEC9760Ç$0000019CT.......T.......T.......T.......T.......T.......T.......T.......T.......T.......$000004B5$000004E1$FFEAB4E0$0000043B$00000425$00000446$00000475$0000048E$00000465$00000486$00000586$000004A6$000001A9$000004A6$00000486$0000019CêÇé*)
  60.