nassi's logo

Nassi Tutorial, Lection 4


[ Lecture 1 | Lecture 2 | Lecture 3 | Lecture 4 ]


Using Profiles and saving source code changes

Probably you want to save all the changes that you have made on 'tut1.c'. Well, nothing is more simple than that. All your edits can be placed in the source code in form of special comments. nassi does this for you, when you click on the save button. A file selection menu is popped up that lets you choose a file name (default is to overwrite the original source).

You must also choose, whether you want to save only the changes that you made with the graphical editor (local) or also the ones, that you did with the global Generator and Output Option menus. (local+global).

Select local+global and save the file as tut1mod.c. It will look like this:

/* a demo program that does nothing useful,
   but contains all Nassi-Shneiderman structure elements
*/

#include <stdlib.h>
#include <stdio.h>

/*  NSC-GLOBAL:
KEY_FONT_COLOR="black"
MIN_WIDTH="0.15"
SHOW_REPEAT="YES"
REPEAT_TEXT="! "
*/

char *function_nr1(char *draw_hints);

void main() {
    printf("result = '%s'\n",function_nr1("some parameter"));
}

char *function_nr1(char *parameter) {
    /*  NSC: HIDE="YES" */

    char  *dummy1,dummy2[100];
    /*  NSC: HIDE="YES" */

    int   i;
    
    do {
      for(dummy1=parameter,i=0; dummy1; dummy1++) {
	printf("%c",*dummy1);
	/*  NSC: ALTERNATE_SWITCH="YES" */

	switch(*dummy1) {
	case 'a':
	  fprintf(stderr,"Too bad, it was an a\n");
	  /*  NSC: FILL_COLOR="red" KEY_FONT_COLOR="yellow" */

	  return function_nr1(dummy1);
	case 'b':
	  fprintf(stderr,"Thank god, I found a b\n");
	  return dummy1;
      default:
	/*  NSC: EXCLUDE="YES" EXCLUDETEXT="check parameter" */

	if(dummy1 == parameter) {
	  printf("- First cut -");
	} else {
	  dummy2[i++] = *dummy1;
	}
	break;
	}
      }
      return parameter+i;
    } while(TRUE);
}

The global changes are placed in a comment at the top of the file that starts with the keyword 'NSC-GLOBAL:'. The local changes are placed in comments just in front of the structure elements to which they apply and start with the keyword 'NSC:' (Nassi Special Comment).

If you like, you can insert these comments in the source yourself, using your favorite text editor. A complete list of possible parameters and values can be found in the appendix of the documentation.

Global changes can also be saved in profiles. When nassi starts up, it searches for a file named .nassirc in your current working directory and in your home directory and eventually loads the first one, that it finds. The format of the profile is the same as of the NSCs. Select 'Save Option to Profile' from the 'File' pulldown menu, to create a profile, that contains all of your global changes.

Some final remarks

This tutorial has not covered all aspects of nassi. The layout of text inside the statements is a major point, that has been left out. Please take a look at the documentation to find out how to nassi has been developed at the ZAM mainly as a tool for the education of 'Mathematical-Technical assistants', to help them document the PASCAL and C programs that they have to write during their training program.

Our future plans for nassi are - of course - bug fixes and small enhancements whenever the need for them arises. Such improvements might be support for non-german locals and a better control over the text layout (e.g. finer granularity of font/color selection).

We will probably not be funded for doing larger extensions like parsers for other programming languages or a source code editor - unless thousands of you are willing to pay for it :-)


[ Lecture 1 | Lecture 2 | Lecture 3 | Lecture 4 ]


Back to main Nassi page