Modula2's journal picture

Modula2

followFollow
🤴
Administrator: eZine
🕒
Created 30 Jan 2023
📄
20 Articles
Modula-2 Tutorial to the programming language Modula-2, a very complete, high level language with many advanced features.
show more

Chapter 16 - Complete example programs

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
The intent of this chapter is to give several example programs that use nearly every capability of Modula-2 as illustrations of large usable programs. The programs are usable utilities, but primarily they are intended to illustrate the method of building up a medium sized program from the various constructs studied in the earlier chapters. BAKLIST.MOD MODULE BakList; (* This program is used to generate a list of all files in all *) (* subdirectories except for the DOS files and the list file which *) (* this program generates. The file FULLDISK.LST is created and *) (* filled in the root directory of the default drive containing *) (* the...

Chapter 15 - Concurrency

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
PREREQUISITES FOR THIS MATERIAL In order to understand this material you should have a good grasp of the material in Part I of this tutorial and at least a cursory knowledge of the material in chapter 14 concerning the pseudo module SYSTEM and especially the ADR and SIZE functions. WHAT IS CONCURRENCY True concurrency is when two processes are taking place at exactly the same time with neither affecting the other in a degrading way. This is possible in many areas of your life, such as when the Grandfather clock is running at the same time as the furnace and the television set. These are different processes all running at the same time. I...

Chapter 14 - Machine Dependent Facilities

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
PREREQUISITES FOR THIS MATERIAL Before attempting to understand this material, you should understand the material presented in Part I of this tutorial and a clear understanding of the material on pointers in Part II. THIS IS WHERE YOU CAN GET INTO TROUBLE Modula-2 does a good job of insulating you from the underlying peculiarities of your computer due to the strong TYPE checking which it does. It can prevent you from making many kinds of rather stupid blunders simply by forcing you to follow its predefined conventions. There are times, however, when you wish to ignore some of its help and do something that is out of the ordinary. If you ...

Chapter 13 - Modules, Local and Global

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
PREREQUISITES FOR THIS MATERIAL Before attempting to understand this material, you should have a good grasp of the principles taught in Part I of this tutorial. None of the material from Part II is required to do a meaningful study of modules in Modula-2. WHAT GOOD ARE MODULES? Modules are the most important feature of Modula-2 over its predecessor Pascal making it very important for you to understand what they are and how they work. Fortunately for you, there are not too many things to learn about them and after you master them you will find many uses for them as you develop programs, and especially large programs. Load and display the ...

Chapter 12 - Pointers and Dynamic Allocation

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
PREREQUISITES FOR THIS MATERIAL In order to understand this chapter, you should have a good grasp of the entirety of Part I and a clear understanding of chapter 11. For certain types of programs, pointers and dynamic allocation can be a tremendous advantage, but most programs do not need such a high degree of data structure. For that reason, it would probably be to your advantage to lightly skim over these topics and come back to them later when you have a substantial base of Modula-2 programming experience. It would be good to at least skim over this material rather than completely neglecting it, so you will have an idea of how pointers...

Chapter 11 - Records

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
PREREQUISITES FOR THIS MATERIAL In order to do a profitable study of this material, you will need a good understanding of all of the material in Part I. The material concerning the scalar type from chapter 11 is also needed. We come to the grandaddy of all data structures in Modula-2, the RECORD. A record is composed of a number of variables any of which can be of any predefined data type, including other records. Rather than spend time trying to define a record in detail, lets go right to the first example program, SMALLREC.MOD. SMALLREC.MOD (* Chapter 11 - Program 1 *) MODULE SmallRec; FROM InOut IMPORT WriteString, WriteCard, WriteLn;...

Chapter 10 - Scalars, subranges, and Sets

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
PREREQUISITES FOR THIS MATERIAL In order to understand the material in this chapter, you should have a fairly good understanding of the material in Part I of this tutorial. A scalar, also called an enumerated type, is a list of values which a variable of that type may assume. Look at the file named ENTYPES.MOD for an example of some scalars. ENTYPES.MOD (* Chapter 10 - Program 1 *) MODULE Entypes; FROM InOut IMPORT WriteString, WriteLn; FROM RealInOut IMPORT WriteReal; TYPE Days = (mon,tue,wed,thu,fri,sat,sun); TimeOfDay = (morning,afternoon,evening,night); VAR Day : Days; Time : TimeOfDay; RegularRate : REAL; EveningPremium : REAL; Nigh...

Chapter 9 - Example programs

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
The programs included in this chapter are intended to be illustrations to you in how to write a complete program. The programs are meant to be useful to you either as an example of how to do some operation or as utility programs for your general use. TIMEDATE - Get Time and Date This program calls one of the DOS functions to get the current time and date. They are input as variables and can be printed or displayed in any format you desire. Your particular compiler may use a different format because there is no standard in Modula-2. This is one of those areas that will probably deviate from compiler to compiler. If you study your documenta...

Chapter 8 - Input/Output

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
A SIMPLE OUTPUT PROGRAM Load and display the file named SIMPLOUT.MOD for an example of the simple output functions. SIMPLOUT.MOD (* Chapter 8 - Program 1 *) MODULE SimplOut; FROM InOut IMPORT WriteString, WriteLn; (* unqualified *) IMPORT InOut; (* This imports every procedure in InOut *) IMPORT Terminal; (* This imports every procedure in Terminal *) VAR Index : CARDINAL; BEGIN WriteString("This is from InOut, "); InOut.WriteString("and so is this."); Terminal.WriteLn; Terminal.WriteString("This is from Terminal, "); Terminal.WriteString('and so is this.'); WriteLn; FOR Index := 1 TO 10 DO InOut.WriteCard(Index,5); END; InOut.Wr...

Chapter 7 - Overall Program Construction

eZine's profile picture
eZine lover (@eZine)
Published in 
 · 30 Jan 2023
We have pretty well covered the topic of how to put all the parts together to build up a program. In this chapter we will go over the whole process in order to clear up any loose ends and have the entire process in one place. There is nothing magic about the way the various pieces fit together but the rules must be followed in order to build a usable program. Load and display the program named OVERPROG.MOD for the first look at the overall structure of the Modula-2 program. OVERPROG.MOD (* Chapter 7 - Program 1 *) MODULE OverProg; (* Overall program construction example *) FROM InOut IMPORT WriteString, WriteLn; PROCEDURE Proc1; BEGIN Wri...
loading
Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT