Example #1
0
static void
dofile(		/* plot a file */
	int  optc,
	char  *optv[],
	char  *file
)
{
	char  stmp[256];
	int  i;
						/* start fresh */
	mgclearall();
						/* type options first */
	for (i = 0; i < optc; i++)
		if (istyp(optv[i])) {
			sprintf(stmp, "include=%s.plt", optv[i]+1);
			setmgvar(progname, stdin, stmp);
		} else
			i++;
						/* file next */
	mgload(file);
						/* variable options last */
	for (i = 0; i < optc; i++)
		if (isvar(optv[i])) {
			sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]);
			setmgvar(progname, stdin, stmp);
			i++;
		}
						/* graph it */
	mgraph();
}
Example #2
0
void
dofile(		/* plot a file */
	int  optc,
	char  *optv[],
	char  *file
)
{
	int  width = 79;
	int  length = 21;
	char  stmp[256];
	int  i;
						/* start fresh */
	mgclearall();
						/* load file */
	mgload(file);
						/* do options */
	for (i = 0; i < optc; i += 2)
		if (optv[i][0] == '+') {
			sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]);
			setmgvar("command line", stdin, stmp);
		} else
			switch (optv[i][1]) {
			case 'w':
				width = atoi(optv[i+1]);
				break;
			case 'l':
				length = atoi(optv[i+1]);
				break;
			default:
				fprintf(stderr, "%s: unknown option: %s\n",
						progname, optv[i]);
				quit(1);
			}

						/* graph it */
	cgraph(width, length);
}