/*---------------------------------------------------------------------------- ** ** Example using LF95 dll's with a simple WINDOWS application. ** This will not run correctly under Win32s. ** ** In a typical application, the C or C++ code would implement a Graphical ** User Interface. ** ** To use : run mkbcf95.bat ** **--------------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #include #include #include #define _X86_ #include "windows.h" HANDLE _stdin_handle; HANDLE _stdout_handle; HANDLE _stderr_handle; /* ** Prototypes used locally. */ void ChooseFactorial(void); int WINAPI WinMain() { /* HANDLE LibHandle; float f; */ AllocConsole(); _stdin_handle = GetStdHandle(STD_INPUT_HANDLE); _stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); _stderr_handle = GetStdHandle(STD_ERROR_HANDLE); ChooseFactorial(); MessageBox(0, "Program Complete", \ "LF95 - DLL Demo", MB_OK | MB_SETFOREGROUND | MB_APPLMODAL); return 0; } /************************************************************************* ** This is how to define prototype for a Fortran Subroutine. ** *************************************************************************/ void __stdcall factorial_demo(long *, long *); void ChooseFactorial() { #define number_of_factorials 12 long num_of_factorials = number_of_factorials; DWORD written; long factorials[number_of_factorials]; char buffer[81]; /* Note that both arguments are passed by reference, the '&' is only ** required on the scalar. */ factorial_demo(factorials, &num_of_factorials); /* Display is crude ... */ WriteConsole(_stdout_handle, "FACTORIALS\n", 11, &written, NULL); sprintf(buffer, "%d %d %d %d %d %d\n", factorials[0], factorials[1], factorials[2], \ factorials[3], factorials[4], factorials[5]); WriteConsole(_stdout_handle, buffer, strlen(buffer), &written, NULL); sprintf(buffer, "%d %d %d %d %d %d\n", factorials[6], factorials[7], factorials[8], \ factorials[9], factorials[10], factorials[11]); WriteConsole(_stdout_handle, buffer, strlen(buffer), &written, NULL); }