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