Source code examples

You can build these example projects by running the script file in the directory containing the sample code. The examples build in the default target for an installation. This is Win32 for Windows based systems, Linux for Linux, and SunOS for Solaris.


Programs to demonstrate the syntaxand use of the generic modules feature of ISO Modula-2.

Directory: examples\generics


Programs to demonstrate the syntaxand use of the object oriented features of ISO Modula-2.

Directory: examples\objects


Programs to demonstrate how to createDLL's and how to use a DLL developed in Modula-2. This example only demonstratesthe "automatic" DLL support built into the development environment.

Directory: examples\dll


Generic. The program demonstrates the basic structure and operation of a Windows API program.  This example can be built for 32-bit or 16-bit Windows.

Clock. This example displays an analog clock in a window. The clock displays the current time.

testSplitter. This example demonstrates the use and features of the SplitterControl module in the runtime library.

Directory: examples\windows


This is an example of a COM objectserver and client. A Visual Basic script file that interfaces to the COM object isalso included. It demonstrates the basic required structure of a COM object serverusing Modula-2 CLASS types. COM objects are Ole2 objects and ActiveX objects areCOM objects. The example is supplied in IDL and ODL sources. You use these sourceswith the IDL compiler utility to generate the COM server and client source code.


This is an example ActiveX container.This sample source is used in conjunction with the IDL2M2 tool. See the IDL2M2 helpfile for further information.


This is an example of a creating aWin32 system wide hook. This example hooks all messages to all windows. This examplealso provides some real functionality, in that it exports functions that can bringa window to the foreground from a background process. The Win32 SetForegroundWindowAPI call will not do this on Win98 and Windows 2000. With this DLL you can do this.Generally it is unwise to force yourself to the foreground since most users wouldbe annoyed if a window popped up while they were doing something else. However someapplication types need this capability.

Directory: examples\hook


FastSignalSem module. Uses the Threadsand MemShare modules to implement a fast version of a semaphore synchronization object.This will be faster than a semaphore implemented in the operating system kernel.

FastMutex module. Uses the Threadsand MemShare modules to implement an inter-process exclusion object with the speedof a user mode spinlock. This will be faster than a mutex implemented in the operatingsystem kernel.

FastEventSem module. Uses the Threadsand MemShare modules to implement a fast version of an event synchronization object.This will be faster than a semaphore implemented in the operating system kernel.

RwLock2 module. Uses the Threads module to implement a multiple reader, single write synchronization object. Demonstrates using the threads module services to implement new synchronization services.

StorageSMP module. If you have a multi-threaded application and you have heavy contention with memory allocation/deallocation, this module shows a simple way to eliminate or reduce the amount of contention. The contention can be an issue because memory heaps are protected with a Mutex.

Diff program. A program to list thedifferences between two text files.

Search program. A program that willsearch multiple files for a given text string.

Whereis program. A program to search a given path for a file of a given name.

crypt. A program which demonstrates the use of the encryption modules in the RTL.

Rebase program. A program to changethe base load address of a Win32 EXE or DLL file. Can automatically group multipleDLL files so that they do not overlap in memory range.

StripDebug program. A program to removeall debug information from a Win32 OBJ or LIB file.

Replace program. A program to updateexisting file(s) in one directory to another directory.

SwitchName program. A program to switch a source file name from long file names <-> short truncated (8.3) file names and back.

DeleteOurself program. A program whichdemonstrates how a program can delete it's exe file from disk after terminating.Only works on Win32.

TabToSpace program. A program whichconverts tab characters in a text file and converts them to space characters.

Directory: examples\misc


GLrect program. A most basic GL programin a Windows window. Shows basic setup of a GL program in a Window.

Directory: examples\opengl


This suite of modules provides a demonstratesthe use of the portable encapsulation of GUI API's and also provides some higherlevel interfaces for GUI programming. These modules are currently implemented forthe Win32 and "UNIX" GTK+ systems. The definition modules of these librarymodules are completely independent of the underlying implementation APIs. The encapsulationis not meant to be a "complete" encapsulation, new encapsulation featuresare added as needed. These modules assume you understand the basics of an event driven,call back (window procedure) program structure.

These modules are the exact modulesthat we use to develop the environment and debugger user interfaces.

Generic - demonstrates the basic usageof WinShell by an application. A real application essentially grows from this point.

TestWinShell - tests demonstrates the most of the functionality of WinShell, DlgShell, BasicDialogs and TextWindows.

Ed - this is the big demo program,and it is also a real world application. It is none other than the text and binaryfile editors from the development environment. It therefore provides extensive demonstrationof the usage of the TextWindows, WinShell and DlgShell library modules. It demonstratesmodal, modeless and tabbed dialogs and the use of toolbars. It also demonstratesa WinShell MDI application (Multiple document interface). To analyze this programstart at the window procedures since after program setup everything starts in theseprocedures.

For the text editor see EdEditor.EditWndProc

For the binary editor see EdHexEditor.HexEditorWndProc

For the MDI frame window see EdMain.EdAppWndProc

Directory: examples\shelldemo


Various traditional compiler benchmarkprograms. Compiler benchmark programs do not represent very well how a compiler willgenerate code for your application. One reason for this is that compiler vendorsgenerally adjust their compiler to do well on benchmark programs. Another reasonis that benchmark programs do not operate like the vast majority of real world programs.

Directory: examples\benchmark