MODULE multi; (* multi-language demonstration program *) (* demonstrates how to call C from Modula and vice versa *) (* There are 3 modules, implemented by the following source files *) (* multi.mod : main module) *) (* multi1.c, multi1.def : module written in C, called from Modula *) (* multi2.mod, multi2.def, multi2.h : module written in Modula, called from C *) FROM math IMPORT atan2; FROM stdlib IMPORT system; FROM stdio IMPORT printf; IMPORT IO; IMPORT multi1; CONST NL = CHAR(10); CONST pi = 3.141592654; VAR x,y:LONGREAL; BEGIN IO.WrStr("IO.WrStr called from Modula" ); IO.WrLn; multi1.x(1,2,3,4); multi1.y(1,2,3,4); system('dir multi*.*'); (* C system function (quite convenient) *) x := 1.2; y := 1.2; printf( "atan2(%f,%f) = %f, pi/4=%f" + NL, x, y, atan2(x,y), LONGREAL(pi/4.0) ); (* Note that you cannot use "\n" in string constants because this is a compile-time notation of the C language, instead use string concatenation of NL *) (* Also note that REAL arguments for printf have to be converted to LONGREAL, since this is what printf expects *) END multi.