1.2 Exercise 2: Browsing code

In this exercise we will use the program 'minmax' from exercise 1 to illustrate code browsing in the Mjolner tool.

1.2.1 What is maxint/minint?

In 'minmax' we use maxint and minint. Find out how they are defined by marking e.g. maxint and clicking the Definition button [421 bytes 32x18 PNG] in the toolbar (or double-click maxint, or press Alt+Right).

[3kb 411x142 PNG]

Maxint is apparently defined in the file 'betaenv'. Double-click the three dots beside maxint.

[3kb 411x142 PNG]

Continue the same way with maxint32 to find out the actual value.

Now we return to 'minmax'. Click the Back button [430 bytes 32x18 PNG] in the toolbar (or right-click and choose 'back', or press Ctrl+Left). Go back until the 'minmax'-program is displayed.

1.2.2 Adjust the 'Minimum'-output right and add zero-padding

Mark min->putint and enter text editing mode. Add (# format::< (##) #) to putint as shown:

[5kb 571x226 PNG]

Double-click format. Because the compiler has not yet checked the text you have just typed, it does not yet know what it means. So answer yes when asked whether to check the program.

[9kb 589x406 PNG]

Now you can see the attributes of putint, they should be self-explanatory. Further bind putint.format in minmax, so that it prints min right adjusted with width 10 and zero-padding.

1.2.3 Which containers are available?

You have probably heard of lists and arraycontainers, but there are many other containers. At the top of the Projects window there is a line that reads 'Std. Libraries/'. Double-click that line or click '+' to open it. Then open 'containers'.

Now all the files in ~beta/containers/ are displayed. Browse through the files and inspect the different kinds of containers. There are quite a few of them.

Whenever you find (*) in a program, it means the program contains a comment at that point. If you double-click the asterisk, the comment is displayed. Double-click again, and the comment is hidden. You can also use Alt+Right or the Definition button [421 bytes 32x18 PNG] in the toolbar.

If ever you find that too much code is being displayed and you would like an overview of the program, you can press Alt+Up. This hides all the details. Double-click to get more details (or mark and press Alt+Right or click the Definition button [421 bytes 32x18 PNG] in the toolbar). To show all details in a selection recursively, press Alt+Down.

1.2.4 What else is in the Beta system?

You should know about the files listed below -- have a quick look at them:


Mjolner Tool Workshop
© 2001-2002 Mjølner Informatics
[Modified: Wednesday September 12th 2001 at 17:10]