essai7.mod 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. MODULE essai7;
  2. (* test minimal de lecture de fichier char par char*)
  3. FROM IOResult IMPORT ReadResults, ReadResult;
  4. FROM TextIO IMPORT ReadRestLine, SkipLine, ReadToken, WriteLn, WriteString, ReadChar;
  5. FROM SeqFile IMPORT OpenRead, OpenWrite, OpenResults, Close, ChanId, read, write;
  6. IMPORT STextIO, SWholeIO;
  7. VAR
  8. theChanId : ChanId;
  9. theResult : OpenResults;
  10. BEGIN
  11. (* principe : on ouvre, on lit les chars les uns après les autres et on les affiche*)
  12. (* une fois arrivé au bout du fichier, on le ferme *)
  13. STextIO.WriteString("Hello you all ! ... be ready for the ISO libs tests !");
  14. STextIO.WriteLn;
  15. STextIO.WriteString("trying to open a file and display the content,char by char");
  16. STextIO.WriteLn;
  17. STextIO.WriteString("trying exeptions ...");
  18. STextIO.WriteLn;
  19. (* ouverture du fichier*)
  20. OpenRead(theChanId, "test126.mod", read, theResult);
  21. IF theResult = noSuchFile THEN
  22. STextIO.WriteString("The file doesn't exist ; halting");
  23. STextIO.WriteLn;
  24. HALT;
  25. ELSE
  26. (* test du résultat*)
  27. IF theResult=opened THEN
  28. (*le fichier est ouvert*)
  29. STextIO.WriteString("file opened!");
  30. ELSE
  31. STextIO.WriteString("Error opening the file");
  32. STextIO.WriteLn;
  33. END;
  34. Close(theChanId);
  35. END;
  36. END essai7.