d_libimpl.LST 466 B

12345678910111213141516171819202122
  1. Listing:
  2. 1 IMPLEMENTATION MODULE DLib;
  3. 2 VAR total : INTEGER;
  4. 3 PROCEDURE Add(n : INTEGER);
  5. 4 BEGIN
  6. 5 total := total + n;
  7. 6 counter := counter + n
  8. 7 END Add;
  9. 8 PROCEDURE Get() : INTEGER;
  10. 9 BEGIN
  11. 10 RETURN total + counter + step
  12. 11 END Get;
  13. 12 BEGIN
  14. 13 (* preset proves the init body runs: zeroed globals would read 0 *)
  15. 14 total := 0;
  16. 15 counter := 2
  17. 16 END DLib.
  18. 0 errors