HOME

Resources

Compilers Tutorials/Papers Libs/Sources Newsgroups FAQ Forums/Lists

Special Areas

GNU Modula-2 Modula-2 CGI Tutorial Howto Setup a Fine Modula-2 Environment Programming with Modula-2 Misc. Modula-2 Related Pages Not-English Modula-2 Pages Downloads Please Sign My Guestbook Code Search

Recommended Links

GNU Modula-2

Modula-2 home page

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 (as I'm not a programmer I haven't reached the necessary knowledge and "abstract thinking"). So here is a result of stepping back...
One of the Modula-2-problems is the lack of interfaces provided for common programming tasks. The compilers implemented in the 80s and 90s are in most cases somehow "minimal" tools for the commandline. But some people wrote stuff that makes Modula-2 a really usable language. If you are searching for information on some special 'problem-field' read on.


[ top ]  Windows API

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 commercially sold compilers providing this interface (XDS and StonyBrook), the only free one I know of is the personal edition of XDS-Modula-2 (free for non-commercial use!). Download the package from Excelsior and have a look at the examples for getting started. If this 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 contains the following information in section 4:
4.11 Is there an applications framework for Windows programming?
A. Try looking at
ftp://ftp.ifi.uio.no/pub/sjr/m2afx.zip or
ftp://ftp.leo.org/pub/comp/os/windows/win3.11/programming/modula/m2afx.zip
This software is an application framework that 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 this compiler. maybe the code is interesting / helps with understanding.


[ top ]  Modula-2 and C


[ top ]  Sockets

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.
Sockets and Modula-2:

  1. Windows Sockets (winsock): only free approach I know about works with XDS-Modula-2. After installing the personal edition, 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 (as the package consists of Header-files only). Until now I just compiled some simple programs - seems to work fine.
  2. BSD Sockets (1): some time ago I wrote "coming soon"... well, meanwhile I searched nearly all available compiler-libraries and didn't find any lib for sockets (any capability for networking anywhere?). If I'm wrong, just tell me, but Mocka, GPM and various C-to-Modula-2 translators do not provide any libraries. You'll have to do this with mixed-language-programming. This is not a big problem if you stick to one of GPM, M2F, XDS or GNU Modula-2. Have a look at the documentation of Excelsiors h2d (already mentioned translator for C-header_2_DEF-module) to get it together that way. Most Linux and BSD compilers provide some ability to interface to C.
  3. BSD Sockets (2): 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.
  4. 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.


[ top ]  X11


[ top ]  Modula-2 and Ada95

This paragraph is under construction. It will concentrate on Modula-2 and GNAT (ftp). Please tell me if you've ever used these compilers together.
If you are searching for information on how to migrate from Modula-2 to Ada95, you may want to have a look at section compilers -> translators. You can find some information on translating M-2 to Ada when following the link provided there.



Get more information


FMP RSS Feed

Modula-2 Webring
[ List_all | Random | Join ]
[ Prev | Next ]

Google


dmoz







Made with CSS