MULTI.LST 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Listing:
  2. 1 MODULE multi;
  3. 2 (* multi-language demonstration program *)
  4. 3 (* demonstrates how to call C from Modula and vice versa *)
  5. 4
  6. 5 (* There are 3 modules, implemented by the following source files *)
  7. 6 (* multi.mod : main module) *)
  8. 7 (* multi1.c, multi1.def : module written in C, called from Modula *)
  9. 8 (* multi2.mod, multi2.def, multi2.h : module written in Modula, called from C *)
  10. 9
  11. 10 FROM math IMPORT atan2;
  12. 11 FROM stdlib IMPORT system;
  13. 12 FROM stdio IMPORT printf;
  14. 13 IMPORT IO;
  15. 14 IMPORT multi1;
  16. 15
  17. 16 CONST NL = CHAR(10);
  18. ***** ^ not supported yet
  19. 17 CONST pi = 3.141592654;
  20. 18 VAR x,y:LONGREAL;
  21. 19 BEGIN
  22. 20 IO.WrStr("IO.WrStr called from Modula" );
  23. ***** ^ not supported yet
  24. ***** ^ not supported yet
  25. ***** ^ not supported yet
  26. 21 IO.WrLn;
  27. ***** ^ not supported yet
  28. ***** ^ not supported yet
  29. 22
  30. 23 multi1.x(1,2,3,4);
  31. ***** ^ not supported yet
  32. ***** ^ not supported yet
  33. ***** ^ not supported yet
  34. 24 multi1.y(1,2,3,4);
  35. ***** ^ not supported yet
  36. ***** ^ not supported yet
  37. ***** ^ not supported yet
  38. 25
  39. 26 system('dir multi*.*'); (* C system function (quite convenient) *)
  40. ***** ^ not supported yet
  41. ***** ^ not supported yet
  42. 27
  43. 28 x := 1.2;
  44. 29 y := 1.2;
  45. 30 printf( "atan2(%f,%f) = %f, pi/4=%f" + NL, x, y, atan2(x,y), LONGREAL(pi/4.0) );
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. 31
  52. 32 (* Note that you cannot use "\n" in string constants because this
  53. 33 is a compile-time notation of the C language, instead use
  54. 34 string concatenation of NL *)
  55. 35
  56. 36 (* Also note that REAL arguments for printf have to be converted to LONGREAL,
  57. 37 since this is what printf expects *)
  58. 38
  59. 39 END multi.
  60. 19 errors