[alt.sources] Fchart part 01/04

fs@uwasa.fi (Filip Sawicki LAKE) (06/04/90)

Submitted-by: fs@chyde
Archive-name: Fchart/part01

#!/bin/sh
# This is Fchart, a shell archive (shar 3.24)
# made 06/04/1990 12:29 UTC by fs@chyde
# Source directory /home2/cc/fs/export
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   3460 -rw-rw-rw- Makefile
#   2949 -rw-rw-rw- README.ins
#   5072 -rw-rw-rw- fchart.c
#  23815 -rw-rw-rw- fchart.doc
#   3906 -rw-rw-rw- fchart.h
#  45623 -rw-rw-rw- fcmd.c
#  22428 -rw-rw-rw- fgraf.c
#  16228 -rw-rw-rw- flblarr.c
#  12994 -rw-rw-rw- fmisc.c
#  20937 -rw-rw-rw- font.c
#  27072 -rw-rw-rw- fstyles.i
#  10184 -rw-rw-rw- futil.c
#   1852 -rw-rw-rw- fversion.c
#    214 -rw-rw-rw- titlepage.ms
#    662 -rw-rw-rw- titlepage.tex
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= Makefile ==============
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X######################################################################
X#
X# WARNING:
X#
X# * if fchart sources are not in the gnuplot directory, define
X#   following variable as a path to it:
X
XGNUP=../gnuplot
X
X#   (default is as you see)
X#   Name this file 'Makefile' and just use 'make ...'
X#
X# * if fchart is in the gnuplot directory, define
X#
X# GNUP=.
X#
X#   and use 'make -f <this_file> ...'
X#   since this file requires presence of the original Makefile
X#
X######################################################################
X
X# where to install executable and help on 'make install'
XDEST=/usr/local/bin/fchart
XHELPDEST=/usr/local/lib/fchart.gih
X
X######################################################################
X
X# substitute your troff command (and any flags) for this one
XTROFF=itroff
X
X# -DFORK if you have vfork()
X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
X# -DNOCOPY if you don't have a memcpy() by any name
X# -DGAMMA if you've got gamma(3)
X# -O if you trust your compiler's optimizer
X# -g if you don't trust me
XCFLAGS = -I$(GNUP) -DVFORK -DBCOPY -DGAMMA -O #-g
X
XOBJS = 	fcmd.o fgraf.o fmisc.o fchart.o futil.o font.o flblarr.o
XOBJG =  $(GNUP)/term.o $(GNUP)/help.o $(GNUP)/scanner.o
X
XCSRC =  fcmd.c fgraf.c fmisc.c fchart.c futil.c font.c flblarr.c
XOSRC =  fstyles.i fchart.h README.ins Makefile fversion.c
XDSRC =  fchart.doc titlepage.ms titlepage.tex
X
X# -lplot if you have -DUNIXPLOT in gnuplot Makefile
XLIBS = -lm -lplot
X
Xfchart: $(OBJG) $(OBJS) fversion.o
X	cc $(CFLAGS) $(OBJG) $(OBJS) fversion.o $(LIBS) -o fchart
X
Xall: install
X
X#copying requires setting TO variable and copies from cwd
Xcopy:
X	cp $(CSRC) $(TO)
X	cp $(OSRC) $(TO)
X	cp $(DSRC) $(TO)
X
Xdoc: gih hlp tex nroff
X
Xinstall: fchart install-unix
X	cp fchart $(DEST)
X	strip $(DEST)
X
X$(OBJS) $(OBJG): $(GNUP)/plot.h 
X
X$(OBJS): fchart.h
X
Xfcmd.o fmisc.o $(GNUP)/help.o: $(GNUP)/help.h
X
Xfgraf.o: fstyles.i
X
Xfcmd.o:
X	cc $(CFLAGS) -c fcmd.c -DHELPFILE=\"$(HELPDEST)\"
X
X$(GNUP)/help.o:
X	( cd $(GNUP) ; make help.o )
X
X$(GNUP)/scanner.o:
X	( cd $(GNUP) ; make scanner.o )
X
X$(GNUP)/term.o:
X	( cd $(GNUP) ; make term.o ) 
X
Xclean:
X	rm -f *.o fchart fchart.gih fchart.toc fchart.tex fchart.nroff
X	rm -f fchart.aux fchart.log fchart.dvi fchart.hlp fchart.ms *~
X
X### [tn]roff documentation
Xtroff: fchart.ms titlepage.ms
X	tbl fchart.ms | eqn | $(TROFF) -ms
X
X# for screen viewing, or printers with backspace/overstrike, remove the -Tlpr
Xnroff fchart.nroff: fchart.ms titlepage.ms
X	tbl fchart.ms | neqn | nroff -ms -Tlpr > fchart.nroff
X
Xms fchart.ms: $(GNUP)/docs/doc2ms fchart.doc
X	$(GNUP)/docs/doc2ms < fchart.doc > fchart.ms
X
X$(GNUP)/docs/doc2ms:
X	( cd $(GNUP)/docs ; make doc2ms )
X
X### LaTeX documentation
Xtex fchart.tex: $(GNUP)/docs/doc2tex fchart.doc
X	$(GNUP)/docs/doc2tex < fchart.doc > fchart.tex
X
Xdvi fchart.dvi: fchart.tex titlepage.tex
X	( latex fchart.tex ; latex fchart.tex )
X
X$(GNUP)/docs/doc2tex:
X	( cd $(GNUP)/docs ; make doc2tex )
X
X### this is how to make fchart.hlp
Xhlp fchart.hlp: $(GNUP)/docs/doc2hlp fchart.doc
X	$(GNUP)/docs/doc2hlp < fchart.doc > fchart.hlp
X
X$(GNUP)/docs/doc2hlp:
X	( cd $(GNUP)/docs ; make doc2hlp )
X
X### this is how to make fchart.gih
Xgih fchart.gih: $(GNUP)/docs/doc2gih fchart.doc
X	$(GNUP)/docs/doc2gih < fchart.doc > fchart.gih
X
X$(GNUP)/docs/doc2gih:
X	( cd $(GNUP)/docs ; make doc2gih )
X
X### For Unix and MSDOS only
Xinstall-unix: fchart.gih
X	cp fchart.gih $(HELPDEST)
X
X### for VMS only
Xinstall-vms: fchart.hlp
X	cp fchart.hlp $(HELPDEST)
X
X
SHAR_EOF
$TOUCH -am 0604152590 Makefile &&
chmod 0666 Makefile ||
echo "restore of Makefile failed"
set `wc -c Makefile`;Wc_c=$1
if test "$Wc_c" != "3460"; then
	echo original size 3460, current size $Wc_c
fi
# ============= README.ins ==============
echo "x - extracting README.ins (Text)"
sed 's/^X//' << 'SHAR_EOF' > README.ins &&
X   IMPORTANT!
X
X   This program requires some knowledge about Gnuplot 2.0 pl0, and a
Xpart of its code. If you don't have it, ftp from the nearest server,
Xand at least print and read the documentation.
X
X**********************************************************************
X 
X   DISCLAIMER 1.
X
X   This program has never had any claims to be The Ultimate Chart
XMaker. It should be treated rather as a previewer before writing
Xproper SAS program or transmitting data to Lotus 1-2-3.
X   And it is no serious work, but effect of several weeks of hacking
Xwell written Gnuplot code.
X
X**********************************************************************
X
X   HOW TO INSTALL FCHART
X
X   Fchart needs the following Gnuplot v2.0 files:
X	docs/*.c
X	term.o
X	plot.h
X	help.h
X	scanner.o
X	help.o
X	(or sources and original Makefile)
X   so there are two basic ways to make it work. Read carefully.
X
X---------------------------------------------
X
X1. Create new directory, and unshar fchart right there.
X   Rename make.fil to Makefile.
X   Edit Makefile:
X	- set LIBS properly, according to your Gnuplot Makefile.
X	- make GNUP point to Gnuplot directory. Path MUST NOT end with "/".
X   Cross your fingers.
X   Type "make fchart"
X   If OK, it's there, named "fchart".
X
X2. Unshar fchart in Gnuplot directory. My files don't have conflicting
X     names, so thre should be no harm done.
X   Edit make.fil:
X	- set LIBS as above.
X	- define "GNUP=."
X   DO NOT RENAME "make.fil" TO "Makefile" !
X   Cross your fingers.
X   Type "make -f make.fil fchart".
X   If OK, it's there, named "fchart".
X
X---------------------------------------------
X
X   To make documentation, choose 'tex', 'dvi', 'troff' or 'nroff'.
X   "make install" will install program as well as built-in help, but
X   before set properly DEST and HELPDEST in Makefile
X   If you'd like to change the code, read the warning in "fgraf.c".
X
X**********************************************************************
X
X   TERMINALS AND OPTIONS
X
X   Fchart takes only one option: type of terminal to produce output
Xfor.  Terminal settings work like in Gnuplot, and also use GNUTERM
Xenvironment variable. In addition, you can define TERM within "fcmd.c"
Xto be your preferred terminal. This overrides GNUTERM, but can be
Xchanged by init file ".fchart". Then the command line option is used,
Xand makes the final change to the terminal.
X   In this release, TERM is set to "tektronix".
X
X**********************************************************************
X
X   DISCLAIMER 2.
X
X   Sorry for the poor quality of the code. I am only a CS student,
Xworking here on the traineeship. I have almost no experience. I don't
Xlike graphics. And you know this side of student life: the only one
Xplace where you have time to sleep are lectures or your work ...
X
X**********************************************************************
X
X   Please send any suggestions to "fs@uwasa.fi"
X
X**********************************************************************
X
SHAR_EOF
$TOUCH -am 0604152590 README.ins &&
chmod 0666 README.ins ||
echo "restore of README.ins failed"
set `wc -c README.ins`;Wc_c=$1
if test "$Wc_c" != "2949"; then
	echo original size 2949, current size $Wc_c
fi
# ============= fchart.c ==============
echo "x - extracting fchart.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > fchart.c &&
X/* fchart - fchart.c */
X/*
X * Gnuplot code
X * Copyright (C) 1986, 1987, 1990   Thomas Williams, Colin Kelley
X *
X * Permission to use, copy, and distribute this software and its
X * documentation for any purpose with or without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and
X * that both that copyright notice and this permission notice appear
X * in supporting documentation.
X *
X * Permission to modify the software is granted, but not the right to
X * distribute the modified code.  Modifications are to be distributed
X * as patches to released version.
X *
X * This software  is provided "as is" without express or implied warranty.
X *
X *
X * AUTHORS
X *
X *   Original Software:
X *     Thomas Williams,  Colin Kelley.
X *
X *   Gnuplot 2.0 additions:
X *       Russell Lang, Dave Kotz, John Campbell.
X *
X *   fchart changes and additions:
X *       Piotr Filip Sawicki
X *
X * send your comments or suggestions to fs@uwasa.fi
X *
X */
X#include <stdio.h>
X#include <setjmp.h>
X#include <signal.h>
X#include "plot.h"
X#include "fchart.h"
X
X#ifdef MSDOS
X#include <io.h>
X#endif
X#ifdef vms
X#include <unixio.h>
X#endif
X#ifdef __TURBOC__
X#include <graphics.h>
X#endif
X
X/* on some compilers (Turbo C) interrupt is a reserved word
X#ifdef MSDOS               
X#define interrupt intrrtn  
X#endif
X*/
X
Xchar *getenv(),*strcat(),*strcpy(),*strncpy(),*sprintf();
X
Xextern char input_line[];
Xextern FILE *outfile;
Xextern int term;
Xextern struct termentry term_tbl[];
X
X#ifndef STDOUT
X#define STDOUT 1
X#endif
X
Xjmp_buf env;
XBOOLEAN interactive;
X
X#ifdef vms
X
X#define HOME "sys$login:"
X
X#else /* vms */
X#ifdef MSDOS
X
X#define HOME "FCHART"
X
X#else /* MSDOS */
X
X#define HOME "HOME"
X
X#endif /* MSDOS */
X#endif /* vms */
X
X#ifdef unix
X#define PLOTRC ".fchart"
X#else
X#define PLOTRC "fchart.ini"
X#endif
X
X
X#ifdef __TURBOC__
Xvoid tc_interrupt()
X#else
Xvoid inter()		/* why not void in GNUPLOT? lint cried */
X#endif
X{
X#ifdef MSDOS
X#ifdef __TURBOC__
X  (void) signal(SIGINT, tc_interrupt);
X#else
X	void ss_interrupt();
X	(void) signal(SIGINT, ss_interrupt);
X#endif
X#else
X	(void) signal(SIGINT, inter);
X#endif
X	(void) signal(SIGFPE, SIG_DFL);	/* turn off FPE trapping */
X	if (term)
X		(*term_tbl[term].text)();	/* hopefully reset text mode */
X	(void) fflush(outfile);
X	(void) putc('\n',stderr);
X	longjmp(env, TRUE);		/* return to prompt */
X}
X
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X/* Register the Borland Graphics Interface drivers. If they have been */
X/* included by the linker.                                            */
X#ifdef __TURBOC__
Xregisterbgidriver(CGA_driver);
Xregisterbgidriver(EGAVGA_driver);
Xregisterbgidriver(Herc_driver);
X#endif
X
X	setbuf(stderr,(char *)NULL);
X	outfile = stdout; 
X
X	interactive = FALSE;
X	init_terminal();  /* Can set term if it wishes. */
X
X#ifdef TERM		/* set term according to predefined type */
X	term = change_term(TERM, strlen(TERM));
X	if (term < 0)
X		term = 0;	/* ignore error */
X#endif
X
X	interactive = isatty(fileno(stdin));
X	if (interactive) {
X		show_version();
X		if (term != 0)
X			fprintf(stderr,"\tTerminal type: '%s'\n\n",term_tbl[term].name);
X	}
X
X	if (!setjmp(env)) {
X		/* first time */
X		interrupt_setup();
X		load_rcfile();
X		if (argc > 1 && change_term(argv[1],strlen(argv[1])) < 1) {
X			interactive = 0;
X			int_error("wrong terminal type as option, aborted",NO_CARET);
X		}
X	} else {
X		/* come back here from int_error() */
X#ifdef vms
X		/* after catching interrupt */
X		/* VAX stuffs up stdout on SIGINT while writing to stdout,
X		   so reopen stdout. */
X		if (outfile = stdout) {
X			if ( (stdout = freopen("SYS$OUTPUT","w",stdout))  == NULL) {
X				/* couldn't reopen it so try opening it instead */
X				if ( (stdout = fopen("SYS$OUTPUT","w"))  == NULL) {
X					/* don't use int_error here - causes infinite loop! */
X					fprintf(stderr,"Error opening SYS$OUTPUT as stdout\n");
X				}
X			}
X			outfile = stdout;
X		}
X#endif                  /* VMS */
X		if (!interactive)
X			done(IO_ERROR);            /* exit on non-interactive error */
X	}
X
X
X	while(TRUE)
X		com_line();
X
X/*	done(IO_SUCCESS);  */
X}
X
X
X/* Set up to catch interrupts */
Xinterrupt_setup()
X{
X#ifdef MSDOS
X#ifdef __TURBOC__
X        (void) signal(SIGINT, tc_interrupt);    /* go there on interrupt char */
X#else
X        void ss_interrupt();
X        save_stack();               /* work-around for MSC 4.0/MSDOS 3.x bug */
X        (void) signal(SIGINT, ss_interrupt);
X#endif
X#else /* MSDOS */
X        (void) signal(SIGINT, inter);   /* go there on interrupt char */
X#endif /* MSDOS */
X}
X
X/* Look for a fchart start-up file */
Xload_rcfile()
X{
X    register FILE *plotrc;
X    static char home[80];
X    static char rcfile[sizeof(PLOTRC)+80];
X
X    /* Look for a fchart init file in . or home directory */
X#ifdef vms
X    (void) strcpy(home,HOME);
X#else
X    (void) strcat(strcpy(home,getenv(HOME)),"/");
X#endif                  /* vms */
X    (void) strcpy(rcfile, PLOTRC);
X    plotrc = fopen(rcfile,"r");
X    if (plotrc == (FILE *)NULL) {
X       (void) sprintf(rcfile, "%s%s", home, PLOTRC);
X       plotrc = fopen(rcfile,"r");
X    }
X    if (plotrc)
X     load_file(plotrc);
X}
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
SHAR_EOF
$TOUCH -am 0604152590 fchart.c &&
chmod 0666 fchart.c ||
echo "restore of fchart.c failed"
set `wc -c fchart.c`;Wc_c=$1
if test "$Wc_c" != "5072"; then
	echo original size 5072, current size $Wc_c
fi
# ============= fchart.doc ==============
echo "x - extracting fchart.doc (Text)"
sed 's/^X//' << 'SHAR_EOF' > fchart.doc &&
X1 fchart
X?
X FCHART is a simple command-driven utility to make bar and pie-charts.
X It should be treated as a previewer before using SAS(R). The program
X is based on the gnuplot v1.2 and 2.0.
X 
X If you are a beginner, first read gnuplot documentation. Other useful
X hints can be found under the following topics:
X 
X `gnuplot` - short comparision of fchart and gnuplot
X 
X `environment` - about environment variables
X 
X `general` - general description of available commands
X 
X `notation` - notation used in this manual
X2 notation
X?notation
X NOTATION USED IN THIS MANUAL:
X@start table
X page     - full-size page of paper or entire screen
X picture  - painted part of page, usually smaller
X /        - delimiter for synonyms of something
X ==       - as above, for whole expression
X { ... }  - optional argument
X |, *, +  - see regexp
X (!)      - something important not to be missed
X <pos>    - positive integer number (real will be truncated)
X <int>    - integer number (real will be truncated)
X <val>    - real number (value)
X <frac>   - fraction of some value (dep. on context):
X            < 0  - error
X            <0,1> - decimal fraction of value
X            > 1  - per cent (%) of value
X            thus 0.5 == 50, 70 == 70%, 1 == 100 (!),
X            for values smaller than 1% use fraction (rare case),
X            for values greater than 1 use %'s (200 == 2 times as ...)
X <range>  - range for several purposes. Two numbers in brackets with
X            ":" as delimiter, eg [1:3], in relation first <= second.
X            Syntax: '[' { <pos> } ':' { <pos> } ']'. First number
X            if omitted is treated as zero (0), second omitted means
X            "to infinity". Both numbers belong to the given range.
X            (!) Omission works different than in Gnuplot.
X#Notion & \  & Explanation \\ \hline
X#page & - &full-size page of paper or entire screen \\
X#picture & - & painted part of page, usually smaller \\
X#/ & - & delimiter for synonyms of something \\
X#== & - & as above, for whole expression \\
X#\verb={ ... }= & - & optional argument \\
X#\verb=|, *, += & - & see regexp \\
X#(!) & - & something important not to be missed \\
X#$<$pos$>$ & - & positive integer number (real will be truncated) \\
X#$<$int$>$ & - & integer number (real will be truncated) \\
X#$<$val$>$ & - & real number (value) \\
X#$<$frac$>$ & - & fraction of some value (dep. on context): \\
X#\ & \ & $<$ 0  - error \\
X#\ & \ & $<$0,1$>$ - decimal fraction of value \\
X#\ & \ & $>$ 1  - per cent (\%) of value \\
X#\ & \ & thus 0.5 == 50, 70 == 70\%, 1 == 100 (!), \\
X#\ & \ & for values smaller than 1\% use fraction (rare case), \\
X#\ & \ & for values greater than 1 use \%'s (200 == 2 times as ...) \\
X#$<$range$>$ & - & range for several purposes. Two numbers in brackets with \\
X#\ & \ & `:' as delimiter, eg \verb=[1:3]=, in relation first $<=$ second. \\
X#\ & \ & Syntax: \verb='[' { <pos> } ':' { <pos> } ']'=. First number \\
X#\ & \ & if omitted is treated as zero (0), second omitted means \\
X#\ & \ & 'to infinity'. Both numbers belong to the given range. \\
X#\ & \ & (!) Omission works different than in Gnuplot. \\
X%Notion@ @Explanation
X%_
X%page@-@full-size page of paper or entire screen
X%picture@-@painted part of page, usually smaller
X%/@-@delimiter for synonyms of something
X%==@-@as above, for whole expression
X%{ ... }@-@optional argument
X%|, *, +@-@see regexp
X%(!)@-@something important not to be missed
X%<pos>@-@positive integer number (real will be truncated)
X%<int>@-@integer number (real will be truncated)
X%<val>@-@real number (value)
X%<frac>@-@fraction of some value (dep. on context):
X% @ @< 0  - error
X% @ @<0,1> - decimal fraction of value
X% @ @> 1  - per cent (%) of value
X% @ @thus 0.5 == 50, 70 == 70%, 1 == 100 (!),
X% @ @for values smaller than 1% use fraction (rare case),
X% @ @for values greater than 1 use %'s (200 == 2 times as ...)
X%<range>@-@range for several purposes. Two numbers in brackets with
X% @ @`:' as delimiter, eg [1:3], in relation first <= second.
X% @ @Syntax: '[' { <pos> } ':' { <pos> } ']'. First number
X% @ @if omitted is treated as zero (0), second omitted means
X% @ @'to infinity'. Both numbers belong to the given range.
X% @ @(!) Omission works different than in Gnuplot.
X
X@end table
X2 fchart vs. gnuplot
X?gnuplot
X Fchart uses the same language as gnuplot, though sometimes the
X meaning of a command/expression can be quite different (!). Fchart
X is data-oriented, thus has no built-in functions and does not perform
X any calculations. For gnuplot compatibility, complex numbers (in
X braces '{}') are accepted, but only their real part is used. Comments
X (#), semicolons(;) and line continuation with backslash (\) work in
X exactly the same way.
X 
X Fchart uses GNUTERM environment variable. Fchart accepts only one
X command-line parameter (unlike Gnuplot (!))  -- type of terminal to
X run on. This has proven to be a good idea.
X2 environment
X?environment
X Fchart uses the same variables as gnuplot, except for FCHARTHELP,
X which can be defined as a path to the help file. On VMS, FCHART$HELP
X should be used instead. 
X In additon, HOME directory is searched on startup for initial file
X called ".fchart" (or equivalent, see "start-up").
X2 commands in general
X?general
X?terminal
X?output
X?size
X?title
X?zero
X?clear
X?exit
X?quit
X?help
X?load
X?pause
X?replot
X?redraw
X?shell
X?!
X?test 
X?read
X?set terminal
X?set output
X?set size
X?set title
X?set zero
X Several commands are directly taken from Gnuplot:
X        clear
X        exit/quit
X        help/?
X        load
X        pause
X        replot
X        shell
X        !
X        test
X These commands are NOT described in this help.
X 
X In addition, there are two synonyms:
X        load/read
X        replot/redraw
X 
X Some other `set`-`show` parameters also have the same meaning:
X        set terminal
X        set output
X        set size
X        set title
X        set zero
X and thus are NOT described here.
X2 save
X?save
X Syntax:
X        save "filename" {{,} "string"}*
X Saves all current settings in the given file. This file can be used
X later with `load`/`read` command. Additional (optional) parameters
X are saved in the file as leading comments, one string per line.
X?set pie
X 
X?set bar
X 
X2 set-show
X?set
X?show
X The `set` command sets LOTS of options. Type:
X        set
X to get names of all possible parameters. The `show` commands shows 
X their settings.  `show all` shows all the settings.
X 
X In addition, `show` groups some related parameters; type:
X 
X        show general
X to see parameters used for any pictures
X 
X        show bar
X to see parameters affecting bar charts
X 
X        show pie
X to see parameters affecting pie charts
X 
X        show version
X to see the version of program you are working in.
X 
X To get information about a parameter, type
X        help <parameter name>
X2 general parameters
X3 parameters for input
X4 range
X?set range
X?show range
X?range
X Syntax:
X        show range
X        set range { <range> }
X (initial and default: `[ : ]`)
X 
X Focuses input on a part of data file, within given range (incl.
X boundaries). Skips comments, and only proper values are counted. 
X Lines are numbered starting from 0.
X4 input (and input format)
X?set input
X?show input
X?input
X Syntax:
X        show input
X        set input { gnuplot | private | customized }
X (initial and default: `private`)
X 
X Sets global type of input files (this can be overriden for
X individual files, and all types can be freely mixed).
X 
X Format of input files:
X 
X        gnuplot
X Accepts generic gnuplot files. Comments are skipped. Empty line
X produces "missing value". Only one number present is used as a value.
X If two are present, the second is treated as a value, and the first is
X taken as a label (for bar or slice). This produces stupidity for some
X data, but works well for other, date-oriented, like "Gnu population in
X Antarctica since 1965".
X 
X        private
X Reverse of gnuplot format: value, blank, label (optional). 
X 
X        customized
X Accepts any fixed-field-length (e.g. SAS) files. No comments. Empty 
X line produces error, and the standard form of missing value (spaces 
X and dot) is supported. To describe required format use `set customized`
X command.
X4 customized
X?set customized
X?show customized
X?customized
X Syntax:
X        show customized
X        set customized { <range> { {,} <range> }}
X (initial and default: undefined)
X 
X Sets ranges for value and (optional) for label: where should they be
X looked for in the line of data file? Ranges cannot overlap. Format is
X quite flexible (see description of ranges), and the only error occurs
X if the input line is shorter than that expected for given starting
X place of value. Characters are numbered from 0.
X3 parameters for picture
X4 frame
X?set frame
X?show frame
X?frame
X Syntax:
X        show frame
X        set frame
X        set noframe
X (initial: ON)
X 
X Controls frame drawing. Frame is drawn around a page (!), not the
X picture.
X4 offsets
X?set offsets
X?show offsets
X?offsets
X Syntax:
X        show offsets
X        set offsets { <frac> {, <frac> {, <frac> {, <frac> }}}}
X (initial and default: 0,0,0,0)
X 
X Sets the size and position of the picture on the page (!). Fractions
X are in terms of screen size and mean, respectively, left, right, top
X and bottom. Of course, it is necessary that left+right and bottom+top
X are less than 100%. E.g., to get the picture in the lower right corner
X of page, specify `set off 50, 0, 50, 0` == `set off 0.5, 0, 0.5, 0`.
X Offsets can be useful for piecharts with very long labels, since labels
X (as well as the picture title) can exceed given boundary (unlike graph
X itself).
X4 logarithmic scale
X?set logscale
X?show logscale
X?logscale
X Syntax:
X        show logscale
X        set logscale
X        set nologscale
X (initial: OFF)
X 
X Obvious. For logscale, all data entries must be > 0, as well as the
X base for bars.
X4 highlighting
X?set highlight
X?show highlight
X?highlight
X Syntax:
X        show highlight
X        set highlight { none | minim | maxim | <pos> }
X (initial and default: `none`)
X 
X Sets global (!) highlighting, for all data. Highlighted element is
X drawn in a different color for bars or explodes for piecharts. Given
X number is just a number of element to be highlighted (in all the
X files), and refers, counting from 0, to _the first value read-in_ (!),
X not to the very first in the file . Can be also set individually for 
X each file.
X4 styles
X?set style
X?show style
X?style
X Syntax:
X        show style
X        set style piechart | adjacent_bars | stacked_bars | layered_bars
X (initial: `adjacent_bars`)
X 
X Sets the style of graph. Names are obvious, go and try.
X4 arrows
X?set arrow
X?set noarrow
X?show arrow
X?arrow
X Syntax:
X        show arrow { tag }
X        set arrow { tag } 
X            { from {page|picture} <val>,<val> }
X            { to {page|picture} <val>,<val> }
X (defaults: <first unused tag>, `picture` 0,0, `picture` 0,0)
X        set noarrow { tag }
X (default: all arrows)
X 
X This command allows you to add pointing arrows to the graph.
X The `tag` is an integer that is used to identify the arrow. 
X If no tag is given, the lowest unused tag value is assigned
X automatically. The tag can be used to delete or change a specific
X arrow. To change any attribute of an existing arrow, use the `set
X arrow` command with the appropriate tag, and specify the parts of the
X arrow to be changed.
X 
X All positions are denoted in any of two coordinate systems: either as
X real numbers <0,1> on the ideal drawing area <0,1>x<0,1>, or as an
X integers for virtual drawing board with resolution 100000x100000.
X 
X Coordinates can refer to physical page or the picture being drawn.
X Arrows in the picture coordinate system follow the changes of the
X picture size and position (see `set offsets`), while those on the page
X are constant. An arrow can of course be drawn `from page` `to picture`
X and vice versa.
X 
X See also `set line`.
X4 lines
X?set line
X?set noline
X?show line
X?line
X Syntax:
X        show line { tag }
X        set line { <same syntax as for arrows> }
X        set noline { tag }
X (defaults: see `set arrow`)
X 
X This command allows you to draw an arbitrary line. Lines are in
X reality arrows without heads, and share with them the tag system.
X 
X Also `show line` == `show arrow` and `set noline` == `set noarrow`.
X 
X For more information, see `set arrow`.
X 
X To change line to arrow, type:
X        set arrow <tag of existing line>
X To change arrow to line, type:
X        set line <tag of existing arrow>
X3 parameters for printed text
X4 format
X?set format
X?show format
X?format
X Syntax:
X       show format
X       set format { "string" }
X (initial and default: "%g")
X 
X Sets format for all numerical values printed on picture (!).
X Restrictions as in gnuplot. This is a very important parameter for
X labeling -- if that doesn't work correctly, change format. Further
X information can be found in the gnuplot manual.
X4 font
X?set font
X?show font
X?font
X Syntax:
X        show font
X        set font { never | when_needed | rotated | always }
X (initial: `when_needed`)
X (default: `always`)
X 
X Sets usage of built-in vector font:
X@start table
X   always, never - obvious
X   when_needed   - font is used when printed text:
X                   * should fit within the given boundary
X                   * is to be rotated, and terminal can't do that
X   rotated       - as `when_needed`, but _always_(!) for rotated text;
X                   useful for some terminals, like 'regis' and 'latex'
X#Value & \ & Meaning \\ \hline
X#\verb=always=, \verb=never= & - & obvious \\
X#\verb=when_needed= & - & font is used when printed text: \\
X#\ & \ & * should fit within the given boundary \\
X#\ & \ & * is to be rotated, and terminal can't do that \\
X#\verb=rotated= & - & as \verb=when_needed=, but \_always\_ (!) for rotated text; \\
X#\ & \ & useful for some terminals, like 'regis' and 'latex' \\
X%Value@ @Meaning
X%always, never@-@obvious
X%when_needed@-@font is used when printed text:
X% @ @* should fit within the given boundary
X% @ @* is to be rotated, and terminal can't do that
X%rotated@-@as 'when_needed', but _always_ (!) for rotated text;
X% @ @useful for some terminals, like 'regis' and 'latex'
X
X@end table
X4 truncate
X?set truncate
X?show truncate
X?truncate
X Syntax:
X        show truncate
X        set notruncate
X        set truncate { <pos> }
X (initial: OFF)
X (default: 0)
X
X Sets maximal length for labels from data files. Command `set truncate`
X will simply ignore all the user labels (see also `set autolabeling`).
X4 autolabeling
X?set autolabeling
X?show autolabeling
X?autolabeling
X Syntax:
X        show autolabeling
X        set autolabeling
X        set noautolabeling
X (initial: OFF)
X 
X Labels read from data files are striped, i.e. all leading and
X trailing spaces are _always_ removed. If all labels are undefined, and
X this parameter is ON, program will generate numbers starting with the
X number of the first read element (i.e. left boundary from `set
X range`). Rules for multiple elements (e.g. one stack or one column in
X "layered style") are different:
X 
X - all undefined : autogenerate (if ON)
X 
X - all the same (with some undefined) : draw (one of) them
X 
X - different : nothing is drawn
X4 labels
X?set label
X?set nolabel
X?show label
X?label
X Syntax:
X        show label { <tag> }
X        set nolabel { <tag> }
X (default: all labels)
X        set label { <tag> } { "text" }
X            { left | centre | right }
X            { at {page|picture} <val>,<val> }
X            { height <val> }
X            { width <val> }
X            { horizontal | vertical |
X              direction left | right | up | down |
X              west | east | south | north |
X              rotation <val> }
X (defaults: <first unused tag>, "", `left`, at `picture` 0,0,
X height 0, width 0, `horizontal`)
X 
X This command places a label on the graph. Here is a brief description
X of the parameters:
X 
X `<tag>` -- integer to identify a label. See also `set arrow`.
X 
X "text" -- text of the label. Defaults to empty: "".
X 
X The third parameter sets desired justification of the label around
X its position. This parameter can be put also _after_ `at` phrase.
X 
X `at` phrase gives the position for the label. For the exact meaning
X of its subparts, see `set arrow`.
X 
X `height` and `width` specify desired height and width of text.
X Unfortunately, text cannot be stretched, so only one of them should be
X given. If both are set, text will be no higher than `height` and no
X wider than `width`, but nothing more is certain.
X Values of `height` and `width` refer to the page or picture, in
X accordance with the `at` phrase. Exact meaning of values for both is
X the same as for positions (see `set arrow`).
X Note: both values refer to the resulting size of character bounding
X box, not character itself (boundig box is 30% higher and 20% wider).
X 
X The last parameter specifies desired direction the text should be
X drawn in. The names are obvious, and `rotation` is an arbitrary angle
X in radians (positive angle counts counterclockwise).
X 
X Rules for using fonts with labels:
X@start table
X       ----------------------------------------------
X       | height & width & direction   ==> font      |
X       ----------------------------------------------
X       |    both  0     | horizontal,  | follows    |
X       |                | east, right, | common     |
X       |                | vertical,    | rules by   |
X       |                | up, north    | `set font` |
X       ----------------------------------------------
X       |      any       | other than   | built-in   |
X       |                | above        | vector f.  |
X       ----------------------------------------------
X       | given one of   |     any      | built-in   |
X       | them or both   |              | vector f.  |
X       ----------------------------------------------
X# height \& width & direction & resulting font \\ \hline
X# both 0 & horizontal, east, right, & follows common rules \\
X# \      & vertical, up, north & given by \verb=set font= \\ \hline
X# any    & other than above & built-in vector font \\ \hline
X# given any of them & any & built-in vector font \\
X%height & width @ direction @ resulting font
X%_
X%both 0 @ horizontal, east, right, @ follows common rules
X%       @ vertical, up, north @ given by "set font"
X%_
X%any    @ other than above @ built-in vector font
X%_
X% given any of them @ any @ built-in vector font
X@end table
X2 settings for bars
X3 autoscale
X?set bar autoscale
X?show autoscale
X?autoscale
X Syntax:
X        show autoscale
X        set bar autoscale
X        set bar noautoscale
X (initial: ON)
X 
X Controls rounding and drawing of axes for bars. Check it. Axes are
X drawn on the left side of bars, looking from base. There's no way to
X change ticking and naming the axis. Ticking algorithm is not very
X clever, although it will never overlap ticking labels.
X3 base
X?set bar base
X?show base
X?base
X Syntax:
X        show base
X        set bar base { <val> }
X (initial and default: 0)
X 
X Sets base for bars. Should be 0 for stacked ones and at least 1 for
X logscale ON. Sometimes useful, though eats a lot of code.
X3 clockwise
X?set bar clockwise
X?show clockwise
X?clockwise
X Syntax:
X        show clockwise
X        set bar clockwise
X        set bar counter_clockwise
X (initial: `clockwise`)
X 
X Direction for drawing bars. "Clockwise" means left to right looking
X from base. Useful for strange gravitation.
X Parameter for pies -- painfully obvious.
X3 gravitation
X?set bar gravitation
X?show gravitation
X?gravitation
X Syntax:
X        show gravitation
X        set bar gravitation { left | top | right | bottom }
X        set bar gravitation { west | north | east | south }
X (initial and default: `bottom`/`south`)
X 
X Sets gravitation for bars, i.e. on what side base should be drawn.
X That is different from just turning page to the left or right.
X3 width
X?set bar width
X?show width
X?width
X Syntax:
X        show width
X        set bar width { <frac> {, <frac> {, <frac> }}}
X (initial and default: 0.2, 0.2, 0.5)
X 
X Sets bar parameters: maximal allowable width (as a fraction of
X picture size), space between bars and space between groups of bars
X (last two as a fraction of bar width chosen by program), respectively.
X If counted bar width is bigger than allowable, this value is taken and
X a smaller graph is centered within picture. There is no way to set the
X standard bar width, determined by picture size and number of bars.
X2 settings for pies
X3 clockwise
X?set pie clockwise
X?show clockwise
X Syntax:
X        show clockwise
X        set pie clockwise
X        set pie counter_clockwise
X (initial: `clockwise`)
X 
X Obvious.
X3 explode
X?set pie explode
X?set explode
X?explode
X Syntax:
X        show explode
X        set pie explode { <params as for bar gravitation> }
X (initial and default: random)
X 
X Sets direction of exploding slice (if highlighting != none).
X Obvious. "Random" means that pie is drawn from top, and a slice will
X explode "outside", just where it should and can.
X3 radius
X?set pie radius
X?show radius
X?radius
X Syntax:
X        show radius
X        set pie radius { <frac> }
X (initial and default: 0.3)
X 
X Sets exploding distance (!) for hightlited slice -- as a fraction
X of the pie radius. Radius depends on the picture size and exploding
X distance, and there is no way to change it.
X3 sample
X?set pie sample
X?show sample
X?sample
X Syntax:
X        show sample
X        set pie sample <pos>
X (initial: 160)
X 
X Number of samples for drawing arcs. Depends on screen resolution.
X3 threshold
X?set pie threshold
X?show threshold
X?threshold
X Syntax:
X        show threshold
X        set pie threshold { <frac> { "name" }}
X (initial and default: 0, "other")
X 
X Threshold for combining slices that are too small into one. Expressed
X as a fraction of whole pie (i.e. 360 deg or 2Pi rad). Must be < 100.
X If highlighting is != none, sices are not combined (!). Combined slice
X is labeled with the given "name".
X2 getting picture -- plot command
X?plot
X?draw
X?tplot
X?tdraw
X There are 6 commands to do that, but in two ways only:
X        plot/draw
X        tplot/tdraw/trans_plot/trans_draw
X 
X They differ in treating incoming values:
X 
X * In `plot`, data from one file create one unit (pie, layer, stack or
X group, depending on style).
X 
X * In `tplot`, one unit is created from many files, thus first value
X from all the files forms one unit, second value next one, and so on.
X It is just like trasposition of data matrix, and hence the name.
X 
X Of course, files need not be the same length, since units can be of
X different size. Files can be of different input style, also.
X 
X Full syntax:
X        plot/tplot
X            { <range> }
X            { (style) } "filename" 
X                { as "name" }
X                { highlighting <type of highlighting> } 
X            { , <same syntax as above> }*
X 
X where :
X `range` overrides `set range` (permanently (!)),
X `style` is the name of style in parenthesis (which means that though
X styles can be freely mixed, only one customized style can be used at
X once -- this limitation probably should be changed), e.g. "(gnu)",
X `as` phrase gives the label to be used instead of filename, and
X `highlighting` sets _local_ highlighting (bogus for `tplot`).
X 
X Note: to turn off highlighting, `none` must be specified explicitly.
X2 start-up
X?startup
X?start
X?.fchart
X?fchart.ini
X When fchart is run, it looks for an initialization file to load. 
X This file is called `.fchart` on Unix , and `FCHART.INI` on other
X systems.  If this file is not found in the current directory, the
X program will look for it in your home directory (under MS-DOS, the
X environment variable `FCHART` should contain the name of this
X directory).
X 
X If this file is found, fchart executes the commands in this file.
X This is most useful for setting your terminal type and other
X parameters.
X 
X By default, output is sent to "stdout", and thus can be redirected.
X All messages go to "stderr".
X2 bugs
X?bugs
X Lots of, probably. The most important is wrong bar centering.
X 
SHAR_EOF
$TOUCH -am 0604152590 fchart.doc &&
chmod 0666 fchart.doc ||
echo "restore of fchart.doc failed"
set `wc -c fchart.doc`;Wc_c=$1
if test "$Wc_c" != "23815"; then
	echo original size 23815, current size $Wc_c
fi
# ============= fchart.h ==============
echo "x - extracting fchart.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > fchart.h &&
X/* Fchart - fchart.h 
X *
X * Copyright (C) 1990 Piotr Filip Sawicki
X *
X * Permission to use, copy, and distribute this software and its
X * documentation for any purpose with or without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and
X * that both that copyright notice and this permission notice appear
X * in supporting documentation.
X *
X * Permission to modify the software is granted, but not the right to
X * distribute the modified code.  Modifications are to be distributed
X * as patches to released version.
X *
X * This software  is provided "as is" without express or implied warranty.
X *
X * send your comments or suggestions to fs@uwasa.fi
X *
X */
X
X#ifdef PROGRAM
X#undef PROGRAM
X#endif
X#ifdef PROMPT
X#undef PROMPT
X#endif
X#ifdef HELP
X#undef HELP
X#endif
X
X#define PROGRAM "FCHART"
X#define PROMPT "command> "
X#define EXP_PROMPT "cont: "
X
X#ifdef vms
X#define HELP  "fchart "
X#else /* vms */
X#define HELP  "/usr/local/bin/help fchart"
X#endif /* vms */
X
X#ifdef TERM
X#undef TERM
X#endif
X
X#ifdef PC
X#define TERM "egalib"
X#else
X#ifdef UNIXPC
X#define TERM "unixpc"
X#else
X#define TERM "tek40xx"		/* put your most common term type here! */	
X#endif 
X#endif
X
Xenum DRAW_STYLE {
X	SBAR, ABARS, LAYB, PIECHART
X};
X
Xenum GRAV_DIR {
X	NORTH=0, WEST=1, SOUTH=2, EAST=3, DEFAULT   /* for exploding parts of piechart only */
X};
X
Xenum INP_STYLE {
X	GNUPLOT, PRIVATE, CUSTOMD
X};
X
Xenum FONT_STYLE {
X	F_NEVER=0, F_WHENN=1, F_ROTAT=2, F_ALWYS=3
X};
X
X#define HL_MIN -3
X#define HL_MAX -2
X#define HL_NON -1
Xextern int HLitem;
X
Xstruct pair {
X	int from, upto;
X};	
X
X#ifdef PC
Xtypedef float vreal;		/* "virtual" real */
X#define CH_INIT_SIZE 50		/* initial size of data chunk */
X
X#else
Xtypedef double vreal;
X#define CH_INIT_SIZE 200
X
X#endif
X
Xstruct chunk {			/* chunk of data */
X	vreal *dval;		/* array of values */
X	char **vlbl;        /* array of labels */
X	int    used;		/* number of used elements */
X	struct chunk *next;	/* next chunk */
X};
X
Xstruct dfile {				/* NORMAL FILE record */			/* DATA_HEAD */
X	char *fname;			/* name of data file */				/* title of the picture */
X	vreal d_min, d_max;		/* min & max data value */			/* min & max of all values */
X	int  points, chunks;	/* number of points and chunks */	/* total num. of points and files */
X	int  makeHL;			/* item to highlit */				/* global HL request */
X	BOOLEAN labels;			/* can we generate labels? */		/* global autolabel request */ 
X	struct chunk *data;		/* head of chunk list */			/* used for indexes when xploting */
X	struct dfile *dnxt;		/* next data file */				/* begining of file list */
X};
X
Xstruct xptr {				/* structure for cross ploting thru several data files */
X	struct chunk *chnp;		/* pointer to current chunk */
X	int vindex;				/* index to current element in it */
X};
X
X#ifdef NO_ROMAN_FONT
Xstruct Char {
X	int wid;
X	unsigned char *def[3];
X};
X#define CHAR_OFF 100
X#define CHAR_GRD 256
X#else
Xstruct Char {
X	int wid;
X	int *def;
X};
X#define CHAR_OFF 10
X#define CHAR_GRD 80
X#endif
X
Xtypedef double MATRIX[3][3];
X
Xextern BOOLEAN interactive;
X
Xenum LAB_ROT {					/* order sagnificant */
X	L_NORMAL, L_BOTTOM, L_UPSIDE, L_TOP, L_RANDOM
X};
X
Xstruct label_def {
X    struct label_def *next;    /* pointer to next label in linked list */
X    int tag;                	/* identifies the label */
X    double x,y;					/* position ... */
X	BOOLEAN paged;				/* on page or picture */
X    enum JUSTIFY pos;
X    char text[MAX_LINE_LEN+1];
X	enum LAB_ROT rot;
X	double h, w, a;				/* height, width, angle */
X};
X
X#define RESOLUTION 100000		/* ideal resolution for labels */
X
Xstruct linearrow_def {
X	struct linearrow_def *next; /* pointer to next arrow in linked list */
X	BOOLEAN arrow;				/* arrow or line */
X    int tag;                	/* identifies the arrow */
X    double sx,sy;           	/* start position ... */
X	BOOLEAN startp;				/* ... on page ? */
X    double ex,ey;          		/* end position ... */
X	BOOLEAN endp;				/* ... on page ? */
X};
X
X
SHAR_EOF
$TOUCH -am 0604152590 fchart.h &&
chmod 0666 fchart.h ||
echo "restore of fchart.h failed"
set `wc -c fchart.h`;Wc_c=$1
if test "$Wc_c" != "3906"; then
	echo original size 3906, current size $Wc_c
fi
echo "End of part 1, continue with part 2"
exit 0