Common Programming Problems using Modula-2
Instead of writing a Modula-2 tutorial I decided to write this getting-started-guide - the turorial I started to write did not get closer to the thing I wanted it to be: simple and illustrated by good examples. Meanwhile the tutorials at Modula2.org were published. So here are some hints for certain areas that are not covered by the tutorials I know of. Most of the links collected here deal with the lack of interfaces provided by Modula-2 compilers for common programming tasks.
No matter if we like it or not, Windows in all its more or less weak implementations is the most used operating system. So the main problem of every language available is an interface to the API of Windows. There are two compilers providing the capability of easily accessing this interface: XDS and StonyBrook Modula-2, the latter being no longer available, the only free one at the moment being XDS-Modula-2. Download the package from Excelsior and have a look at the examples for getting started. The great theForger's Win32 API Tutorial adapted by Frank Schoonjans for Modula-2 should be a more in depth reading and if this still is not enough information, have a look at the Translations of Example Programs in Charles Petzold's book "Programming Windows 95" from Visual C++ to Modula-2. This helps a lot and it is almost all the information you can get. For german-speaking people there is another great resource that can be found at the University of Graz (Austria): this is a tutorial on programming Windows with Modula-2 containing simple examples and a basic introduction to the concepts of Windows. Used compiler is XDS-Modula-2. For more complex examples have a look at the Sources Store for Modula-2 and Oberon. You may download a RichEdit-package, an ODBC-interface and some other really interesting material there.
Mister Shigeo Hayashi also translated some example programs from a Windows-book to Modula-2. Useful.
The Modula-2 FAQ (still) contains links in section 4 which point to an archive named m2afx.zip. Both locations are no longer serving the file but it is available from Modula2.org. The file contains an applications framework for Windows programming: The software implements a number of classes that encapsulate the weirdness of the Windows C API and attempts to present it in a cleaner way to the Modula-2 programmer. But "this software will only work on the TopSpeed Modula-2 compiler version 3.00 and later" as it uses the object-oriented extensions of TopSpeed Modula-2.
[ top ] Modula-2 and C
- GNU Modula-2 has the ability to cooperate with C. It also comes with h2def, a translator for C header files. It's under development but compared to h2d by XDS it is (1) open source and (2) works with GNU Modula-2.
- Maybe another easy way to work on a mixed language project that uses Modula-2 and C is using a translator. But you've got to like the idea of translators.
- XDS/Excelsior offers the utility h2d as part of their Modula-2/Oberon-2 compiler-package. This package translates C header-files into Modula-2 definition-modules. makes your job a lot easier. Examples of translated interfaces to various functions of the Windows-API can once again be found at the Sources Store for Modula-2 and Oberon-2 Programming. h2d is a real powerful must-have!
- Mr. Enger offers the paper Interfacing Modula-2 to C. This paper describes what you have to do (also available as .pdf).
BSD-sockets (and the winsock-api) are something like a standard for programming the internet (not only: the concept is to standardize interprocess communication). Nearly every modern programming language gives you the possibility to use sockets, where opening a socket is like opening something like an endpoint for an abstract communications-channel. There are some good introductions related to this subject available - for a start have a look at the quick and dirty primer for bsd-sockets and the winsock-primer by Jim Frost. These short introductions also provide links to get in deeper. Best tutorial (basics and some advanced topics) I found is Beej's Guide to Network Programming using Internet Sockets (and have a look at his pages as they are a treasury).
Sockets and Modula-2:
- Windows Sockets (winsock): The only free approach I know of works with XDS-Modula-2. After installing the compiler, you'll have to go to the Sources Store for Modula-2 and Oberon. Download the file 'WinSock2.zip' from there and extract it from the base-directory of your XDS installation. This gives you the usual interface to the winsock-dll (via a definition module which interfaces to the winsock library). Until now I just compiled some simple programs - seems to work fine.
- BSD Sockets (1): Just use GNU Modula-2. The compiler comes with a simple example using ClientSocket.def. Have a look to get started. For other compilers you'll have to interface to C - which is possible with most Linux and BSD compilers.
- BSD Sockets (2): Page Six is a service bot for IRC channels written in XDS Modula-2 (Sources) using sockets. Very helpful to get started.
- BSD Sockets (3): The OS/2 version of PMOS by Peter Moylan contains a file 'sockets.def' wich provides a simple interface to bsd-sockets. Once again, mighty PMOS shows its power... I didn't find this earlier 'cause I never downloaded the OS/2 version.
- M2Lib by H. Kleinschmidt (available from the local download-area) is an impressive library for Atari Computers which can be used with a variety of compilers for this platform. Clicking my way through the directories of the library I found a module for handling sockets. The documentation (which is in German) says this lets you carry out elementary sockets-operations using MiNT-net by Kay Roemer. As I do not have an Atari I was not able to test this.
- There are some alternatives available. First one I know of is part of the XDS Modula-2 for Linux package by Excelsior. This is really great, as it is really the most complete solution. And it does not only contain the usual Xlib headers but also definition modules for handling .xpm files.
- Gardens Point Modula-2 offers an interface to X11 plus samples. Examples work fine - haven't done much more until now.
- Searching for new links I found Nicky's Software page. You may download the file 'XModula.tgz' there, plus a version of the mtc-translator, wich will hopefully work with XModula. the readme says it should also work with mocka. description from homepage: "This is a set of files that will allow you to use the X-Windows (version 11, revision 6, also known as X11R6) library calls directly with the Modula-2 programming language. It includes the full Modula-2 foreign definition modules for the most important headers of X-Windows: Xlib.h, X.h, Xutil.h and keysyms.h"
[Using 6.xx browsers, I wasn't able to download the file as usually possible - I had to right-click the download-link, save the file to my harddisk and after that rename to the original names given at the homepage. newer browsers saved them to my disk as .html, but it has to be .tgz ... ]
- Some time ago Steve Giess has kindly contributed a port of xmodula to GNU Modula-2. While I cannot find it in the official sourcetree of the compiler I am sure you can ask for it in the GNU Modula-2 mailing list.
- The Olsen & Associates Portable Modula-2 Library contains the basic definition modules to be used with Sun Modula-2 and X11 (I heard some installations still exist...). The readme says the material is untested. The Olsen Library is available from the local download-area.
Get more information
Modula-2 Webring
[ List_all |
Random |
Join ]
[ Prev |
Next ]
Contact, suggestions, submission of news items: