Development Tools

Prospero Fortran Windows Library

The Prospero Fortran Windows Library allows Prospero Fortran programmers to produce true Windows applications written entirely within the Fortran language.

Windows 3, Windows NT and (more recently) Windows 95 have become popular and very widely-used. For many computer users, as distinct from programmers, the consistent user interface across many different programs makes it a productive environment. The programmer sees many advantages too: the support for numerous devices, graphics cards, printers, mice and so on means that the programmer can concentrate on the program and not the hardware. The GDI provides a rich graphics environment with powerful drawing facilities and a wide choice of fonts. The programmer, however, sees disadvantages: Windows has a reputation for being very difficult to learn, and for many programmers there is the added burden of learning C, and either re-coding other working Fortran code into C or struggling with mixed-language programming. Although Windows programming is not easy, the idea that it is nearly impossible is a myth. Straightforward Windows applications are readily developed from example programs by changing and adding where necessary. The Prospero Fortran Windows Library both provides examples and also enables Windows applications to be written in Fortran.

Standard Fortran programs may be run with no modification to the source code. All programs run in extended memory, so there is no 640K memory limit to worry about. If READ or WRITE statements are used with standard input or output, then a window is opened and maintained automatically by the library, and all input and output is directed to it. This facility is available to any Windows program, so additional PRINT statements can be inserted during debugging. Run-time errors may also be directed to this window.

However, Standard Fortran programs are not typical Windows applications. A typical Fortran program accepts input from the command-line or by prompting for data files, performs its calculations (during which time the machine appears dead), and comes up with the answers some seconds, minutes, hours or even days later. True Windows applications have menus and dialog boxes for commands and selections of options. They allow user input from the keyboard and mouse, and interact with other programs through mechanisms such as the clipboard. Most importantly, they must be prepared to respond to user actions and to run concurrently with other tasks. Many Fortran programs are already driven by user action, rather than prompting the user for information. These programs could benefit from becoming full Windows applications. As may be expected the extra work involved in producing a Windows application can be considerable; the benefits to the end user may be as large, and the potential audience for the application correspondingly enlarged.

The Fortran Windows Library

It is not possible to directly access Windows subroutines from Fortran, so library bindings are required. These bindings are provided by Prospero in the form of a library of routines which can be called from Fortran and expect Fortran arguments (e.g. INTEGER*4 and CHARACTER variables). The bindings transform these arguments to the C-style arguments that Windows expects, and then call the Windows routines.

The Windows Library contains:

The library may be used to produce Windows programs running on any machine with an 80286 processor or above and Windows 3.0 (or above) or OS/2 2.0. On an 80286 based system or with OS/2 2.0 there is a limit of 1MByte on individual variable and common block sizes. On an 80386 and above the limit is 16MByte.

The following simple example of a windows processing function shows that it may be a Windows program, but it still looks like Fortran:

INTEGER*4 FUNCTION MainWndProc(hWnd, wMsg, wParam, lParam) INTEGER*4 hWnd, wMsg, wParam, lParam INCLUDE 'WINCONST' INCLUDE 'GLOBAL' INCLUDE 'W_WM_' PARAMETER (IDM_ABOUT=100) INTEGER*4 lpProcAbout, dummy EXTERNAL About MainWndProc = 0 IF (wMsg .eq. WM_DESTROY) THEN CALL IFPostQuitMessage (0) RETURN END IF IF (wMsg .eq. WM_COMMAND) THEN IF (wParam .eq. IDM_ABOUT) THEN lpProcAbout = IFMakeprocInstance(About , hInst) dummy = IFDialogBox(hInst, ! current instance + 'AboutBox', ! resource to use + hWnd, ! parent handle + lpProcAbout ! About () instance address + ) CALL IFFreeProcInstance (lpProcAbout) RETURN END IF END IF MainWndProc = IFDefWindowProc(hWnd, wMsg, wParam, lParam) RETURN END

Programming Windows

It takes dozens of lines of code to produce even the simplest Windows application. Much of this code will appear in every application and represents a starting point.

Common to nearly all applications is a main window. The programming of this is handled by a large processing function which receives messages and processes them accordingly. Most messages can be ignored and passed straight on to a default handling function. Others will need to be processed, including ones to re-draw the screen when a portion needs re-painting (e.g. when another window covering the window is moved away). Appropriate user commands will need to be processed: commands from the pull-down menus, the keyboard and a mouse. A well thought out program will grow out of simple beginnings by the addition of extra message processing code. In the example above, only one message is processed, which handles the user selecting About from the pull-down menu. The default handling takes care of the rest: it is possible to move and re-size the window, to pull down menus and close down the application without any explicit user code. Several demonstration programs are supplied and these may be used to form the basis of many larger applications.

System Requirements:
The Prospero Fortran Windows Library requires Prospero Fortran version 2.1, and a machine running Windows 3.01 (or later) or OS/2 2.0. At least an 80286 processor is required.

The Microsoft SDK or equivalent is recommended. This kit contains essential tools and documentation. The Windows Library manual does not fully document the Windows routines. There are numerous programming books on Windows 3 covering a number of approaches.

Pricing: The Prospero Fortran Windows Library is available from Prospero Software for 120 pounds (excluding VAT & delivery); contact distributors for local pricing.

For further information, contact:

Prospero Development Software Ltd

London SW15 6EP
England

Prospero@ProsperoSoftware.com

Distributors
United Kingdom

Grey Matter
Prigg Meadow
Ashburton
Devon TQ13 7DF
England

Email maildesk@greymatter.co.uk

System Science
1 Bradley's Close
White Lion Street
London N1 9PN
England

Germany

EDV-Beratung Friedrich Pluennecke
Hinterm Dorfe 21
D-38268 Lengede
Germany

fp@pluennecke.de

Japan

Lifeboat Inc.
3-6 Kanda-Nishikicho
Chiyoda-Ku
Tokyo 101
Japan

sales@lifeboat.co.jp

Prospero is a registered trademark of Prospero Software Ltd. Microsoft, MS-DOS and Windows are trademarks of Microsoft Corp. IBM, PC-DOS, OS/2 and Warp are trademarks of International Business Machines Corp.

Details correct as of June 1996. Prospero Software has a policy of continuous product improvement and reserves the right to alter specifications and prices without notice.


Development Tools Top of page