CARDSTR.DEF 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. (* !LIBRARY! *) DEFINITION MODULE CardStr;
  2. (* Proposed BSI/ISO Standard Modula-2 I/O Library
  3. * Copyright Roger Henry, University of Nottingham
  4. * Version WG/4.01, February 1989
  5. * Permission is given to copy this Definition Module, with the
  6. * copyright notice intact, for the purposes of evaluation and test.
  7. * At the stage of a formal draft standard, Copyright will be transferred
  8. * to BSI (and through BSI to other recognised standards bodies).
  9. * Status: for review by BSI/IST/5/13;
  10. for review by ISO/IEC JTC1/SC22/WG13
  11. --* this version editted to comform to D105 kjg September 1989 *--
  12. *)
  13. IMPORT ConvTypes;
  14. FROM ConvTypes IMPORT ScanProgress, ScanProc;
  15. (* the text form of an unsigned whole number is *)
  16. (* [whitespace] digit {digit} *)
  17. PROCEDURE Scan(
  18. this: CHAR; VAR progress: ScanProgress; VAR nextScanner: ScanProc
  19. );
  20. TYPE
  21. ConvResults = ConvTypes.ConvResults;
  22. PROCEDURE Format(str: ARRAY OF CHAR): ConvResults;
  23. (* pre: "str" has a string value *)
  24. (* post: returned value corresponds to format of string *)
  25. (* value with respect to the type CARDINAL *)
  26. PROCEDURE Value(str: ARRAY OF CHAR): CARDINAL;
  27. (* pre: "str" has a string value *)
  28. (* and format is "allRight" with respect to CARDINAL *)
  29. (* post: returned value is the corresponding CARDINAL *)
  30. PROCEDURE Take(
  31. str: ARRAY OF CHAR; VAR card: CARDINAL; VAR format: ConvResults
  32. );
  33. (* pre: "str" has a string value *)
  34. (* post: either value of "format" is "allRight", *)
  35. (* value of "card" is the corresponding CARDINAL *)
  36. (* or value of "format" is "outOfRange", *)
  37. (* value of "card" is MAX(CARDINAL) *)
  38. (* or value of "format" is "wrongFormat" *)
  39. (* value of "card" is undefined *)
  40. (* or value of format is "noData" *)
  41. (* value of "card" is unchanged *)
  42. TYPE
  43. Alignment = ConvTypes.Alignment;
  44. PROCEDURE Length(card: CARDINAL): CARDINAL;
  45. PROCEDURE Give(
  46. VAR str: ARRAY OF CHAR; card: CARDINAL; width: CARDINAL; where: Alignment);
  47. (* post: as far as capacity of "str" allows, *)
  48. (* the character representation of "card" is contained in "str" *)
  49. (* in a field of at least "width" characters *)
  50. (* left, centre (numeric), or right justified; *)
  51. (* for the special case of "width" = 0, a leading space is written *)
  52. END CardStr.