FST (Fitted) Modula-2 Version 4.0 Documentation

[Previous]  [Contents]  [Next]


5. A LITTLE TOUR THROUGH THE SYSTEM

After you finish the installation as described above, please copy the files identified as the "system tour files" in the READ.ME file to your work disk or directory.

Because we do not know your particular system configuration, in the following examples we will assume the worst possible scenario. Therefore, some of the capabilities of this system will not be fully exploited. Specifically, we will not invoke the linker or run the programs from the compiler menu.

5.1 THE TOUR

First, we will look at the unnatural case of compiling, linking and running a program that works the first time around. Please execute the following commands:

   MC SIEVE /C
   M2LINK SIEVE /O
Well, that's it! Ready to run...

   SIEVE

Now for the more usual case:

   MC BADSIEVE

From the compiler menu, select 'C' for compile. Gee, that was quick! Press RETURN to take a look at our errors...
The cursor is now positioned at the location of the first error. Using the keys Ctrl-E (find next error) and Ctrl-P (find previous error) you may visit all the errors flagged by the compiler. All the while, the editor shows the error description on the top line of the screen. But, going back to the first error...

We really confused the compiler when we mistakenly typed in '.' instead of '..' in the range declaration. Move the cursor back (left arrow key) to where the '.' is, type in another '.', and that should fix that! As you will see as you type Ctrl-E, that single error caused the compiler to dislike a few other things on that same line; we will just ignore those errors and go on.

Go on to the next error location (line 22). This time, we should have used a ']' but typed '}' instead. The backspace key will delete the offending character; now, type the ']' in its place. And that is that. Shall we try to compile the program again?
Press Alt-S to save the file, Alt-Q to leave the editor and, back at the main menu, select 'C'. More errors?!
These errors should have been detected during pass2 of the compiler; If not, you may try to fix these errors and recompile, or you may opt for loading and compiling the new file BADSIEV1.MOD, which contains the earlier fixes.

Going back to the editor... We find that we used the identifier 'cnt' which is undefined; we really meant to use count. So, moving the cursor around with the cursor keys and/or deleting characters with the backspace or delete key, please replace 'cnt' by 'count'.

Searching for the next error... The next error occurred during the processing of the call to WriteCard. What happened here is that WriteCard requires 2 parameters, the second one being the size of the field to display. So, to fix it, let's insert a comma after 'count' and some number (for example 'count,4'). Any more errors? No, that is it...

We now save the file (Alt-S), quit the editor (Alt-Q) and recompile (c). Now, the program should have compiled without errors. If not, you may recompile BADSIEV2.MOD instead. We may now quit the compiler (q).

By now, we have some program that has compiled clean (BADSIEVE, BADSIEV1 or BADSIEV2). In what follows, we will assume all went well and we have BADSIEVE.

If you look at the directory, you will see the new object module created as a result of the previous exercise (BADSIEVE.M2O). The compiler always writes its output to a file with the extension 'M2O'. Let us link and test the program:

   M2LINK BADSIEVE /L

We use the /L option so that the line number information written out by the compiler to the object file will be preserved by the linker. We will need this information later.

   BADSIEVE

Hmmm... A runtime error at line 22. Let's see what happened...

   MC BADSIEVE

Pick 'E' to go into the editor and, either move the cursor down to the line indicated, or let the editor find it with Alt-G.

So, what is the problem? Well, we declared the 'flag' array to have a maximum index of 8190, but 'j' got bigger than that (the FOR loop will increment 'j' up to the value of 10000). You may fix the problem by deleting the '10000' and typing in its place 'SIZE'. Recompile the program, link it, and run it. Did it work? Good.

It is time for you to experiment on your own. But, before you do much more, you may want to check out the Editor chapter of the documentation.