
Nassi Tutorial, Lecture 1
[
Lecture 1 |
Lecture 2 |
Lecture 3 |
Lecture 4 ]
This is a small tutorial that should give you a first impression of nassi's
capabilities. It is divided into 4 lectures:
- Lecture 1 lets you create your first diagrams
- Lecture 2 tells you how to use nassi's option buttons
- Lecture 3 introduces nassi's graphical editor
- Lecture 4 shows how to make your edits persistent
Unless you want to run nassi in batch-mode, just type nassi -
optionally followed by the name of a C or PASCAL source file, that you want to
work on.
Assume you have the following file named
tut1.c in your current working directory:
/* a demo program that does nothing useful,
but contains all Nassi-Shneiderman structure elements
*/
#include <stdlib.h>
#include <stdio.h>
char *function_nr1(char *draw_hints);
void main() {
printf("result = '%s'\n",function_nr1("some parameter"));
}
char *function_nr1(char *parameter) {
char *dummy1,dummy2[100];
int i;
do {
for(dummy1=parameter,i=0; dummy1; dummy1++) {
printf("%c",*dummy1);
switch(*dummy1) {
case 'a':
fprintf(stderr,"Too bad, it was an a\n");
return function_nr1(dummy1);
case 'b':
fprintf(stderr,"Thank god, I found a b\n");
return dummy1;
default:
if(dummy1 == parameter) {
printf("- First cut -");
} else {
dummy2[i++] = *dummy1;
}
break;
}
}
return parameter+i; /* an important comment */;
} while(TRUE);
}
|
and you type nassi tut1.c. Then nassi's GUI should come up:
The main window consists of several areas.
- The top line contains two pulldown menus. Most of the functions of these
menus can also be accessed through one of the buttons in the row below.
The help menu will bring up documentation (and the order form).
- The 4 leftmost buttons are used for exiting nassi, loading, reloading and saving of
source files.
- The next group of buttons selects printing, previewing (with Ghostview)
and creation of output files in one of the supported formats.
- The last group of buttons starts popup menus for customization of
sourcecode parsing, diagram and output-file generation respectively.
- The text area in the left part of the window holds a list of all functions,
subroutines and 'exclude blocks' (see Lecture 3). Selecting one of these with
the mouse will bring up the Nassi-Shneiderman diagram of this function in
the canvas area right to the text area.
- At the bottom of the main window, error messages and warnings are displayed
in a scrollable status area.
After clicking on 'function_nr1' and resizing the main window, you will see the
following:
You can already learn quite a few things about nassi from this simple
example.
- each diagram consists of a header with function name and parameter list and
a box that contains the function body.
- All supported structure elements can be found in this example:
- simple statements
- 2-way decisions (if/then/else)
- multiway-decisions (switch/case)
- loops that check the exit-condition before and after the loop body
- Statements that contain a function call, are marked with a double line.
- 'for' loops are displayed as if they were while loops.
- C keywords, build-in datatypes and user-defined function names are displayed in
a different color.
- The C parser does not distinguish between statements and variable declarations.
You will see in a moment what you can do, if you don't want the latter to show up
in your diagram (The PASCAL parser does not have this limitation).
- Sometimes the text may look a little damaged. This is because the layout is
generated for Postscript fonts, and the mapping to X-fonts is not always perfect.
The Postscript Output will be OK.
On the next page, you will learn how to use the option buttons in the top row.
[
Lecture 1 |
Lecture 2 |
Lecture 3 |
Lecture 4 ]
Back to main Nassi page