home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / reldb / part01 next >
Encoding:
Internet Message Format  |  1989-09-17  |  72.8 KB

  1. Subject:  v20i004:  Relational database and graphing tools, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: hafro.is!gunnar (Gunnar Stefansson)
  7. Posting-number: Volume 20, Issue 4
  8. Archive-name: reldb/part01
  9.  
  10. This package includes the following tools:
  11.     This is scat, a simple scattergram program, which we have found very
  12.     useful for all sorts of simple line drawing, with possible labels etc.
  13.     Scat writes plot(5) commands to the standard output.
  14.  
  15.     Math reads columnar data from the standard input and outputs a few
  16.     summary statistics.
  17.  
  18.     The following plot(1) filters:
  19.     xplot        -- X11
  20.     hpglplot    -- HP GL
  21.     graplot        -- GRAP
  22.  
  23.     and others.
  24.  
  25. #!/bin/sh
  26. # to extract, remove the header and type "sh filename"
  27. if `test ! -d ./reldb.src`
  28. then
  29.   mkdir ./reldb.src
  30.   echo "mkdir ./reldb.src"
  31. fi
  32. if `test ! -s ./reldb.src/recode.c`
  33. then
  34. echo "writting ./reldb.src/recode.c"
  35. cat > ./reldb.src/recode.c << '\Rogue\Monster\'
  36. /* recode:
  37.  
  38.     Author: gunnar@hafro.is (early 1988)
  39.  
  40.     Recodes first column in data (std. inp) according to
  41.     1st+2nd column in filename of argument list.
  42. */
  43. #include <stdio.h>
  44. #define MAXOLD 10000    /* old values must be in the range 0 thru MAXOLD */
  45. #define MAXLIN 1000    /* maximum length of input line */
  46. #define USE "Usage : recode codefile < datafile \n"
  47. main(argc,argv)
  48. int argc;
  49. char *argv[];
  50. {
  51.     char    inplin[MAXLIN];
  52.     char    head[MAXLIN];    /* header: first of code file, then data file */
  53.     char    *ptr;        /* temporary char pointer--loops over head*/
  54.     char    *nmptr;        /* point to name of new code variable in head */
  55.     int    o,n;        /* old/new codes from codefile */
  56.     int    code[MAXOLD];    /* code transformations */
  57.     FILE    *fp,*fopen();
  58.  
  59.     if((fp=fopen(argv[1],"r"))==NULL)    /* open code file */
  60.         errlog(USE);
  61.     fgets(head,MAXLIN,fp);            /* header line from code file */
  62.     fgets(inplin,MAXLIN,fp);        /* skip second line */
  63.     code[0] = -1;
  64.     while(fgets(inplin,MAXLIN,fp)!=NULL){
  65.         if(sscanf(inplin,"%d%d",&o,&n)!=2)    /* get code data */
  66.             errlog("Error in code-file\n");
  67.         o++;
  68.         if(o<0||o>=MAXOLD)
  69.             errlog("Error - old value outside range in codefile\n");
  70.         code[o]=n;            /* store code data */
  71.     }
  72.     fclose(fp);                /* done with code file */
  73.     for(ptr=head;*ptr!='\t';ptr++)        /* skip name of old col*/
  74.         ;                    /* from code file */
  75.     nmptr= ++ptr;                /* points to new col name */
  76.     while(*ptr!='\n')
  77.         putchar(*ptr++);        /* put new code name */
  78.     *ptr='\0';                /* end the name */
  79.     putchar('\t');                /* end the first outcol.*/
  80.     fgets(inplin,MAXLIN,stdin);        /* get old data header */
  81.     fputs(inplin,stdout);            /* append to output line */
  82.     for(ptr=nmptr;*ptr;ptr++)        /* output correct # dashes */
  83.         putchar('-');
  84.     putchar('\t');                /* and the tab */
  85.     fgets(inplin,MAXLIN,stdin);        /* get the dataline of dashes */
  86.     fputs(inplin,stdout);            /* append to above dashes */
  87.     while(fgets(inplin,MAXLIN,stdin)!=NULL){/* read a data line */
  88.         if(sscanf(inplin,"%d",&o)!=1)
  89.             errlog("recode : cannot read code from dataline\n");
  90.         o++;
  91.         if(o<0||o>MAXOLD)
  92.             errlog("recode : code in data outside range \n");
  93.         printf("%d\t%s",code[o],inplin);
  94.     }
  95. }
  96. errlog(s)
  97. char    *s;
  98. {
  99.     fprintf(stderr,"%s",s);
  100.     exit(1);
  101. }
  102.  
  103. \Rogue\Monster\
  104. else
  105.   echo "will not over write ./reldb.src/recode.c"
  106. fi
  107. if `test ! -s ./reldb.src/regress.c`
  108. then
  109. echo "writting ./reldb.src/regress.c"
  110. cat > ./reldb.src/regress.c << '\Rogue\Monster\'
  111. /*
  112.     Simple linear regression
  113.  
  114.     Input : A reldb file of the form :
  115.     
  116.         xname    yname
  117.         -----    -----
  118.         x1    y1
  119.         x2    y2
  120.         etc
  121.         
  122.     Usage : regress < datafile
  123.     
  124.     Output : to std. out, all sorts of regression statistics.
  125.  
  126. NOTE: regress in Gary Perlman's package is much better than this
  127. and should be preferred
  128.  
  129.                                     */
  130.  
  131. #include <stdio.h>
  132. main(){
  133.     char xname[30],yname[30];    /* variable names */
  134.     char buf[60];
  135.  
  136.     int c;            /* to recieve errors from scanf */
  137.  
  138.     float x,y;        /* input vbls */
  139.  
  140.     double n,sumx,sumy,sumxx,sumyy,sumxy;    /* obvious meaning */
  141.     double xbar,ybar;    /* ditto */
  142.     double stdevx,stdevy;
  143.     double ssxx,ssyy,ssxy;    /* sum of sq. deviations */
  144.     double sstot,sse,ssreg;    /* the ss's in the anova table */
  145.     double mstot,mse,msreg; /* the ms's ------------------- */
  146.     double t,F;        /* t*t=F for testing slope =0 */
  147.     double alpha,beta;    /* regression coefficients */
  148.     double r,r2;        /* correlation & explnd variation */
  149.     double sqrt();
  150.  
  151.     c= -1;
  152.     while((xname[++c]=getchar())!='\t')    /* get name of x */
  153.         ;
  154.     xname[c]='\0';
  155.     c= -1;
  156.     while((yname[++c]=getchar())!='\n')    /* get name of y */
  157.         ;
  158.     yname[c]='\0';
  159.     gets(buf,60);                /* skip 2nd reldb line */
  160.  
  161.     while((c=scanf("%f %f",&x,&y))!=EOF){
  162.         n+=1.;sumx+=x;sumy+=y;sumxx+=x*x;sumyy+=y*y;sumxy+=x*y;
  163.     }
  164.  
  165.     ssyy=sumyy-sumy*sumy/n;    /* prepare regression estimates */
  166.     ssxx=sumxx-sumx*sumx/n;    /* so compute numerators for variances */
  167.     ssxy=sumxy-sumx*sumy/n;    /* and covariances */
  168.     xbar=sumx/n;        /* not to forget means */
  169.     ybar=sumy/n;
  170.     stdevx=sqrt(  ssxx/(n-1.));
  171.     stdevy=sqrt(  ssyy/(n-1.));
  172.  
  173.     beta=ssxy/ssxx;        /* slope estimate */
  174.     alpha=ybar-beta*xbar;   /* intercept -- */
  175.     r=ssxy/sqrt(  ssxx*ssyy);
  176.     r2=ssxy*ssxy/(ssxx*ssyy);
  177.  
  178.     sstot=ssyy;        /* now for the anova table */
  179.     ssreg=beta*beta*ssxx;    /* compute the sums of squares, */
  180.     sse=sstot-ssreg;    
  181.     mstot=sstot/(n-1.);    /* the mean squares */
  182.     mse=sse/(n-2.);
  183.     msreg=ssreg/1.;
  184.     F=msreg/mse;        /* and the F-value */
  185.  
  186.     printf("Number of observations %.0f\n",n);
  187.     printf("Average of %s-values    %.2f,",xname,xbar);
  188.     printf("\taverage of %s-values    %.2f .\n",yname,ybar);
  189.  
  190.     printf("Std. dev. in %s-values  %.2f, ",xname,stdevx);     
  191.     printf("\tstd. dev. in %s-values  %.2f .\n",yname,stdevy); 
  192.  
  193.     printf("Correlation coefficient between %s and %s : %.4f",xname,yname,r);
  194.     printf("\tExplained variation %.2f\n",r2);
  195.     printf("Estimated regression line : %s = ",yname);
  196.     printf(" %.2f + %.2f * %s \n\n",alpha,beta,xname);
  197.  
  198.     printf("Anova table \n\n");
  199.     printf("Source\t\t\tSS\t\tdf\t\tMS\t\tF\n");
  200.     printf("------------------------------------------");
  201.     printf("--------------------------------\n");
  202.     printf("Regression \t %10.2f \t %10.2f \t %10.2f \t %10.2f\n",ssreg,1.,msreg,F);
  203.     printf("Error\t\t %10.2f \t %10.2f \t %10.2f\n",sse,n-2.,mse);
  204.     printf("------------------------------------------");
  205.     printf("--------------------------------\n");
  206.     printf("Total \t\t %10.2f \t %10.2f \t %10.2f\n",sstot,n-1.,mstot);
  207. }
  208. \Rogue\Monster\
  209. else
  210.   echo "will not over write ./reldb.src/regress.c"
  211. fi
  212. if `test ! -s ./reldb.src/rename.sh`
  213. then
  214. echo "writting ./reldb.src/rename.sh"
  215. cat > ./reldb.src/rename.sh << '\Rogue\Monster\'
  216. #!/bin/sh 
  217. #
  218. # Shell script to rename columns in a reldb data file.
  219. #
  220. # Usage :  rename old1 new1 old2 new2 old3 new3 ...
  221. #
  222. # The script simply builds a (fairly complex) sed-command.
  223. # The command is inserted into the string cmd and
  224. # is later piped into the shell, along with the data.
  225. # Note that echo will not work due to tab-expansion
  226. cmd=sed
  227. while(true)
  228. do
  229.     if [ X$1 != X ]
  230.     then
  231.         name1=$1
  232.         name2=$2
  233.         shift
  234.         shift
  235.         cmd="$cmd -e "\""1s/\\(    *\\)$name1\\(    *\\)/\\1$name2\\2/"\"
  236.     else
  237.         ( cat <<xxxx==
  238. $cmd
  239. xxxx==
  240. cat - )  | sh
  241.         exit
  242.     fi
  243. done
  244.  
  245. \Rogue\Monster\
  246. else
  247.   echo "will not over write ./reldb.src/rename.sh"
  248. fi
  249. if `test ! -s ./reldb.src/see.sh`
  250. then
  251. echo "writting ./reldb.src/see.sh"
  252. cat > ./reldb.src/see.sh << '\Rogue\Monster\'
  253. #!/bin/sh
  254. #
  255. # Trivial implementation of "see"
  256. #
  257. cat -vte $1
  258. \Rogue\Monster\
  259. else
  260.   echo "will not over write ./reldb.src/see.sh"
  261. fi
  262. if `test ! -s ./reldb.src/sideview.sh`
  263. then
  264. echo "writting ./reldb.src/sideview.sh"
  265. cat > ./reldb.src/sideview.sh << '\Rogue\Monster\'
  266. #!/bin/sh
  267. #
  268. # sideview -- put a table on its "side" and view a record at a time
  269.  
  270. awk 'BEGIN{FS="    "}
  271. NR==1{for(i=1;i<=NF;i++){
  272.     ind[i]=$(i)
  273.     }
  274.      }
  275. NR>2{      print "";print "Faersla nr : ",NR-2
  276.  for(i=1;i<=NF;i++)
  277.     printf("%10s  %s\n", ind[i],$(i))
  278.     }' < $1
  279. \Rogue\Monster\
  280. else
  281.   echo "will not over write ./reldb.src/sideview.sh"
  282. fi
  283. if `test ! -s ./reldb.src/sorttable.sh`
  284. then
  285. echo "writting ./reldb.src/sorttable.sh"
  286. cat > ./reldb.src/sorttable.sh << '\Rogue\Monster\'
  287. #!/bin/sh
  288. #
  289. # sorttable -- sort a reldb table
  290.  
  291. trap "rm tmp$$ tmp1$$" 15 2 1 
  292. opt="-t    "
  293. col=""
  294. file=""
  295. sortcol=""
  296. for i
  297. do
  298. case $1 in
  299.     '-n')
  300.         opt="$opt -n"
  301.         shift
  302.         ;;
  303.     '-f')
  304.         file=$2
  305.         shift
  306.         shift
  307.         ;;
  308.     *)
  309.         col="$col $1"
  310.         shift
  311.         ;;
  312. esac
  313. done
  314.  
  315. sed -n "1,2p
  316. 3,\$w tmp$$" < $1  | tee tmp1$$
  317.  
  318. read columns < tmp1$$
  319.  
  320. for i in $col
  321. do
  322.     colnr=0
  323.     for j in $columns
  324.     do
  325.         if [ X$i  = X$j ]
  326.         then
  327.             sortcol="$sortcol +$colnr"
  328.         fi
  329.         colnr=`expr $colnr + 1`
  330.     done    
  331. done
  332. sort $opt $sortcol tmp$$
  333. rm tmp$$ tmp1$$
  334.  
  335.  
  336. \Rogue\Monster\
  337. else
  338.   echo "will not over write ./reldb.src/sorttable.sh"
  339. fi
  340. if `test ! -s ./reldb.src/subtotal.c`
  341. then
  342. echo "writting ./reldb.src/subtotal.c"
  343. cat > ./reldb.src/subtotal.c << '\Rogue\Monster\'
  344. /* subtotal.c 
  345.  
  346. Usage: subtotal by by-columnlist on on-columnlist < reldb-table
  347.  
  348. Controls doing subtotals of the on-columns for each set of fixed
  349. values of all the by-columns.
  350.  
  351. This program just scans its arguments and generates a 
  352. new command of the form: project colnames | addup number,
  353. where addup adds up the relevant columns (assuming they
  354. are in a decent order - making life much simpler).
  355.  
  356. Revision history:
  357.     Original author:
  358.         gunnar@hafro.is (1986 ?)
  359.     Revisions due to incorrect string handling:
  360.         gunnar@hafro.is (April, 1989)
  361. */
  362. #include <stdio.h>
  363. #ifdef BSD
  364. #include <sys/wait.h>
  365. #endif
  366. #include <strings.h>
  367. #define MAXCMD 1000
  368. main(argc,argv)
  369. int    argc;
  370. char    *argv[];
  371. {
  372.     char    command[MAXCMD];
  373.     char    *usage="Usage : subtotal by b1 b2 b3 ... on d1 d2 d3 ... < file\n";
  374.     char    *ptr=command;
  375.     int    count=0;
  376.     int    debug=0;
  377.  
  378.     ++argv;
  379.     if(!strcmp(*argv,"-d")){
  380.         debug=9;    /* assume full debug wanted */
  381.         fprintf(stderr,"subtotal-debug level 9 used\n");
  382.         argc--;
  383.         ++argv;
  384.     }
  385.     if(strcmp(*argv,"by"))
  386.         errlog(usage);
  387.     argv++;
  388.     argc--;
  389.     argc--;
  390.     if(debug)fprintf(stderr,"subtotal: setting up project command\n");
  391.     strcpy(ptr,"project ");
  392.     ptr+=strlen(ptr);
  393.     while(strcmp(*argv,"on")){
  394.         strcpy(ptr,*argv);
  395.         if(debug)fprintf(stderr,"\tby-column:%s\n",*argv);
  396.         ptr+=strlen(ptr);
  397.         *ptr++=' ';
  398.         count++;
  399.         argc--;argv++;
  400.         if(argc<=0)
  401.             errlog(usage);
  402.     }
  403.     argv++;argc--;
  404.     if(debug)fprintf(stderr,"subtotal: finishing project command\n");
  405.     while(argc){
  406.         strcpy(ptr,*argv);
  407.         if(debug)fprintf(stderr,"\ton-column:%s\n",*argv);
  408.         ptr+=strlen(ptr);
  409.         *ptr++=' ';
  410.         argc--;argv++;
  411.     }
  412.     if(debug){
  413.         sprintf(ptr," | addup %d %d\n",debug,count);
  414.         fprintf(stderr,"COMMAND:->%s<-\n",command);
  415.     } else {
  416.         sprintf(ptr," | addup %d\n",count);
  417.     }
  418.     system(command);
  419. #ifdef BSD
  420.     wait((union wait *)0);
  421. #else
  422.         wait(0);
  423. #endif
  424.     exit(0);
  425. }
  426. errlog(s)
  427. char    *s;
  428. {
  429.     fprintf(stderr,"%s",s);
  430.     exit(1);
  431. }
  432. \Rogue\Monster\
  433. else
  434.   echo "will not over write ./reldb.src/subtotal.c"
  435. fi
  436. if `test ! -s ./reldb.src/union.sh`
  437. then
  438. echo "writting ./reldb.src/union.sh"
  439. cat > ./reldb.src/union.sh << '\Rogue\Monster\'
  440. #!/bin/sh
  441. #
  442. # Now this has to be one of the most trivial commands in the world:
  443. #
  444. # union -- concatanate two reldb tables, using Unix tools.
  445. #
  446. cat $1
  447. shift
  448. for i
  449. do
  450.     tail +3 <$i
  451. done
  452.  
  453. \Rogue\Monster\
  454. else
  455.   echo "will not over write ./reldb.src/union.sh"
  456. fi
  457. if `test ! -s ./reldb.src/reldb`
  458. then
  459. echo "writting ./reldb.src/reldb"
  460. cat > ./reldb.src/reldb << '\Rogue\Monster\'
  461. \Rogue\Monster\
  462. else
  463.   echo "will not over write ./reldb.src/reldb"
  464. fi
  465. if `test ! -s ./reldb.src/Makefile`
  466. then
  467. echo "writting ./reldb.src/Makefile"
  468. cat > ./reldb.src/Makefile << '\Rogue\Monster\'
  469. #
  470. # BINDIR is where the binaries and scripts go. Note that a simple 'make'
  471. # will also install. You'll want to define BINDIR as ../bin untill
  472. # you know things work.
  473. #
  474. BINDIR=../bin
  475. #
  476. # Use -DBSD for all BSD-systems
  477. #     -DSYSV for sysv-style systems
  478. #
  479. CFLAGS= -DDEBUG=0 -DBSD
  480. BINARIES=$(BINDIR)/addcol \
  481.     $(BINDIR)/addup \
  482.     $(BINDIR)/check \
  483.     $(BINDIR)/compute \
  484.     $(BINDIR)/select \
  485.     $(BINDIR)/count \
  486.     $(BINDIR)/columnlist \
  487.     $(BINDIR)/dataplotpre \
  488.     $(BINDIR)/dbdict \
  489.     $(BINDIR)/dbe.change \
  490.     $(BINDIR)/dbe.add \
  491.     $(BINDIR)/invert \
  492.     $(BINDIR)/jointable \
  493.     $(BINDIR)/math \
  494.     $(BINDIR)/matrix \
  495.     $(BINDIR)/mulregpre \
  496.     $(BINDIR)/number \
  497.     $(BINDIR)/pairpre \
  498.     $(BINDIR)/plokk \
  499.     $(BINDIR)/preplot \
  500.     $(BINDIR)/project \
  501.     $(BINDIR)/recode \
  502.     $(BINDIR)/rename \
  503.     $(BINDIR)/see \
  504.     $(BINDIR)/sideview \
  505.     $(BINDIR)/sorttable \
  506.     $(BINDIR)/bplokk \
  507.     $(BINDIR)/subtotal \
  508.     $(BINDIR)/testdb \
  509.     $(BINDIR)/union
  510.  
  511.  
  512. # Note that "regress" is not installed, since the regress program
  513. # of |Stat is much better, esp. with the "mulregpre" interface.
  514. reldb : $(BINARIES)
  515.     touch reldb
  516. uninstall :    
  517.     rm -f $(BINARIES)
  518.  
  519. $(BINDIR)/addup : addup.c
  520.     cc $(CFLAGS) -o $(BINDIR)/addup addup.c -lm
  521. $(BINDIR)/compute : compute.c
  522.     cc $(CFLAGS) -o $(BINDIR)/compute compute.c -lm
  523. $(BINDIR)/select : $(BINDIR)/compute
  524.     ln $(BINDIR)/compute $(BINDIR)/select
  525. $(BINDIR)/count : count.c
  526.     cc $(CFLAGS) -o $(BINDIR)/count count.c -lm
  527. $(BINDIR)/matrix : matrix.c
  528.     cc $(CFLAGS) -o $(BINDIR)/matrix matrix.c -lm
  529. $(BINDIR)/plokk : plokk.c
  530.     cc $(CFLAGS) -o $(BINDIR)/plokk plokk.c -lm
  531. $(BINDIR)/project : project.c
  532.     cc $(CFLAGS) -o $(BINDIR)/project project.c -lm
  533. $(BINDIR)/recode : recode.c
  534.     cc $(CFLAGS) -o $(BINDIR)/recode recode.c -lm
  535. $(BINDIR)/regress : regress.c
  536.     cc $(CFLAGS) -o $(BINDIR)/regress regress.c -lm
  537. $(BINDIR)/subtotal : subtotal.c
  538.     cc $(CFLAGS) -o $(BINDIR)/subtotal subtotal.c -lm
  539. $(BINDIR)/check : check.sh
  540.     cp  check.sh $(BINDIR)/check
  541.     chmod +x $(BINDIR)/check
  542. $(BINDIR)/bplokk : bplokk.sh
  543.     cp  bplokk.sh $(BINDIR)/bplokk
  544.     chmod +x $(BINDIR)/bplokk
  545. $(BINDIR)/columnlist : columnlist.sh
  546.     cp  columnlist.sh $(BINDIR)/columnlist
  547.     chmod +x $(BINDIR)/columnlist
  548. $(BINDIR)/dataplotpre : dataplotpre.sh
  549.     cp  dataplotpre.sh $(BINDIR)/dataplotpre
  550.     chmod +x $(BINDIR)/dataplotpre
  551. $(BINDIR)/dbdict : dbdict.sh
  552.     cp  dbdict.sh $(BINDIR)/dbdict
  553.     chmod +x $(BINDIR)/dbdict
  554. $(BINDIR)/dbe.add : dbe.add.sh
  555.     cp  dbe.add.sh $(BINDIR)/dbe.add
  556.     chmod +x  $(BINDIR)/dbe.add
  557. $(BINDIR)/dbe.change : dbe.change.sh
  558.     cp  dbe.change.sh $(BINDIR)/dbe.change
  559.     chmod +x  $(BINDIR)/dbe.change
  560. $(BINDIR)/invert : invert.sh
  561.     cp  invert.sh $(BINDIR)/invert
  562.     chmod +x $(BINDIR)/invert
  563. $(BINDIR)/jointable : jointable.sh
  564.     cp  jointable.sh $(BINDIR)/jointable
  565.     chmod +x $(BINDIR)/jointable
  566. $(BINDIR)/math : math.sh
  567.     cp  math.sh $(BINDIR)/math
  568.     chmod +x $(BINDIR)/math
  569. $(BINDIR)/mulregpre : mulregpre.sh
  570.     cp  mulregpre.sh $(BINDIR)/mulregpre
  571.     chmod +x $(BINDIR)/mulregpre
  572. $(BINDIR)/number : number.sh
  573.     cp  number.sh $(BINDIR)/number
  574.     chmod +x $(BINDIR)/number
  575. $(BINDIR)/pairpre : pairpre.sh
  576.     cp  pairpre.sh $(BINDIR)/pairpre
  577.     chmod +x $(BINDIR)/pairpre
  578. $(BINDIR)/preplot : preplot.sh
  579.     cp  preplot.sh $(BINDIR)/preplot
  580.     chmod +x $(BINDIR)/preplot
  581. $(BINDIR)/rename : rename.sh
  582.     cp  rename.sh $(BINDIR)/rename
  583.     chmod +x $(BINDIR)/rename
  584. $(BINDIR)/see : see.sh
  585.     cp  see.sh $(BINDIR)/see
  586.     chmod +x $(BINDIR)/see
  587. $(BINDIR)/sideview : sideview.sh
  588.     cp  sideview.sh $(BINDIR)/sideview
  589.     chmod +x $(BINDIR)/sideview
  590. $(BINDIR)/sorttable : sorttable.sh
  591.     cp  sorttable.sh $(BINDIR)/sorttable
  592.     chmod +x $(BINDIR)/sorttable
  593. $(BINDIR)/union : union.sh
  594.     cp  union.sh $(BINDIR)/union
  595.     chmod +x $(BINDIR)/union
  596. $(BINDIR)/addcol : addcol.sh
  597.     cp addcol.sh $(BINDIR)/addcol
  598.     chmod +x $(BINDIR)/addcol
  599. $(BINDIR)/testdb : testdb.sh
  600.     cp testdb.sh $(BINDIR)/testdb
  601.     chmod +x $(BINDIR)/testdb
  602. \Rogue\Monster\
  603. else
  604.   echo "will not over write ./reldb.src/Makefile"
  605. fi
  606. if `test ! -s ./reldb.src/flattotable.sh`
  607. then
  608. echo "writting ./reldb.src/flattotable.sh"
  609. cat > ./reldb.src/flattotable.sh << '\Rogue\Monster\'
  610. #!/bin/sh
  611. #
  612. # flattotable - convert files with tabs and spaces to reldb table,
  613. #               where only one tab separates columns.
  614. #
  615. # Eliminates tabs/spaces at beginning and end of lines.
  616.  
  617. sed -e 's/^[     ]*//' \
  618.     -e 's/[     ]*$//' \
  619.     -e 's/[     ][     ]*/    /g'
  620. \Rogue\Monster\
  621. else
  622.   echo "will not over write ./reldb.src/flattotable.sh"
  623. fi
  624. if `test ! -s ./reldb.src/testdb.sh`
  625. then
  626. echo "writting ./reldb.src/testdb.sh"
  627. cat > ./reldb.src/testdb.sh << '\Rogue\Monster\'
  628. #!/bin/sh
  629. #
  630. # testdb -- user script for testing reldb programs.
  631. #
  632.  
  633. RELDBDIR=/usr/local/src/Reldb/testdb
  634.  
  635. if [ ! -d $RELDBDIR ]
  636. then
  637.     echo "I can't seem to find the test data and programs"
  638.     echo "Please edit my RELDBDIR variable properly"
  639.     echo "(It is now set to $RELDBDIR, which is incorrect)"
  640.     exit 1
  641. fi
  642.  
  643. # Go home first - no need to clutter discs
  644. cd
  645. if [ ! -d testdb ]
  646. then
  647.     mkdir testdb
  648. fi
  649. cd testdb
  650. PWD=`pwd`
  651. echo Testing reldb programs in $PWD
  652. echo "Copying programs and data - hold on ..."
  653. cp $RELDBDIR/* .
  654. echo "Running 'make' - this willl result in a number of .tmp-files"
  655. make
  656. echo "Feel free to examine the .tmp-files. If everything is"
  657. echo "working properly, they should be identical to the"
  658. echo "corresponding .res-files"
  659. \Rogue\Monster\
  660. else
  661.   echo "will not over write ./reldb.src/testdb.sh"
  662. fi
  663. if `test ! -d ./scat.src`
  664. then
  665.   mkdir ./scat.src
  666.   echo "mkdir ./scat.src"
  667. fi
  668. if `test ! -s ./scat.src/Makefile`
  669. then
  670. echo "writting ./scat.src/Makefile"
  671. cat > ./scat.src/Makefile << '\Rogue\Monster\'
  672. BINDIR=../bin
  673. OBJ=scat.o readdat.o  plttics.o pttxt.o trans.o recplot.o extplotlib.o
  674. all: scat
  675. scat : $(OBJ)
  676.     cc -o scat $(OBJ)  -lplot
  677. install: scat
  678.     cp scat $(BINDIR)
  679. clean: 
  680.     rm -f scat $(OBJ)
  681. \Rogue\Monster\
  682. else
  683.   echo "will not over write ./scat.src/Makefile"
  684. fi
  685. if `test ! -s ./scat.src/README`
  686. then
  687. echo "writting ./scat.src/README"
  688. cat > ./scat.src/README << '\Rogue\Monster\'
  689. This is scat, a simple scattergram program, which we have found very
  690. useful for all sorts of simple line drawing, with possible
  691. labels etc. Scat writes plot(5) commands to the standard output.
  692.  
  693. 1. 'make' compiles.
  694. 2. 'make install' installs.
  695. 3. 'scat -h' gives all the options.
  696. 4. See ../testgr for a number of graphics options.
  697.  
  698. 5. Use the reldb programs to work on files like 'data'. This should
  699.    not be done with options within scat.
  700.  
  701. Note that with the -E option, scat will generate plots where the
  702. Y-axis label is "sideways", labels in the figure are centered etc.
  703. For this to work, you need an extended plot-filter, such as the ones 
  704. enclosed (in ../plot.src).
  705.  
  706. The enclosed Makefile assumes the user wants to link with the
  707. plot-library, to generate plot(5) output. This is then normally
  708. piped through the plot-filters (e.g. hpglplot or xplot, which are
  709. enclosed. If none of the plot-stuff is available (notably in Xenix
  710. and HP-UX), it should still be possible to link scat with hpglplot.o
  711. or xplot.o and get a binary version of scat, which will work with that
  712. single device. This is neither clean nor ideal, but it does provide
  713. more usefulness.
  714. \Rogue\Monster\
  715. else
  716.   echo "will not over write ./scat.src/README"
  717. fi
  718. if `test ! -s ./scat.src/defs.h`
  719. then
  720. echo "writting ./scat.src/defs.h"
  721. cat > ./scat.src/defs.h << '\Rogue\Monster\'
  722. #include <stdio.h>
  723.  
  724. #define MAXPTS    1500    /* max no of data points (lines in file) */
  725. #define MAXCOLS    25    /* max no of data columns */
  726. #define MAXTXT    100    /* max length of name of column */
  727. \Rogue\Monster\
  728. else
  729.   echo "will not over write ./scat.src/defs.h"
  730. fi
  731. if `test ! -s ./scat.src/plttics.c`
  732. then
  733. echo "writting ./scat.src/plttics.c"
  734. cat > ./scat.src/plttics.c << '\Rogue\Monster\'
  735. #include "defs.h"
  736. extern int debuglevel;
  737. extern char *xformat;
  738. extern char *yformat;
  739.  
  740. plot_tics(wxmin,wxmax,wymin,wymax,xmin,xmax,xdelta,ymin,ymax,ydelta)
  741. double    xmin,xmax;        /* min, max of all x-values */
  742. double    ymin,ymax;        /* min, max of all y-values */
  743. double    xdelta,ydelta;        /* increment for x/y tick marks */
  744. double  wxmin,wxmax,wymin,wymax;
  745. {
  746.     int i=0,j=0;
  747.     int outx,outy;
  748.     char number[80];
  749.     double numlargeticks;
  750.     double x, y;
  751.  
  752.     linemod("solid");
  753.     if (debuglevel) {
  754.         fprintf(stderr,"xformat= %s\n",xformat);    
  755.         fprintf(stderr,"yformat= %s\n",yformat);    
  756.     }
  757.  
  758.     labelplace("u");
  759.     x=xmin;                /* x axis */
  760.     sprintf(number,xformat,x);    /* char version of axis number */
  761.  
  762.     transf_data(wxmin,wymin,wxmax,wymax,x,ymin,&outx,&outy);
  763.     move(outx,outy);
  764.     transf_data(wxmin,wymin,wxmax,wymax,x,ymin-(ymax-ymin)*.03,&outx,&outy);
  765.     cont(outx,outy);
  766.     transf_data(wxmin,wymin,wxmax,wymax,x,ymin-(ymax-ymin)*.035,&outx,&outy);
  767.     move(outx,outy);
  768.     label(number);
  769.  
  770.     numlargeticks=(((xmax-xmin)/xdelta)/5);
  771.     for(i=(int)numlargeticks;i--;){    /* large tick loop */
  772.         for(j=5;j--;){        /* small tick loop */
  773.             transf_data(wxmin,wymin,wxmax,wymax,x,ymin,&outx,&outy);
  774.             move(outx,outy);    /* draw small tick */
  775.             transf_data(wxmin,wymin,wxmax,wymax,x,ymin-(ymax-ymin)*.015,&outx,&outy);
  776.                     cont(outx,outy);
  777.             x+=xdelta;        /* x for next small tick */
  778.         }
  779.         transf_data(wxmin,wymin,wxmax,wymax,x,ymin,&outx,&outy);
  780.         move(outx,outy);        /* next large tick */
  781.         transf_data(wxmin,wymin,wxmax,wymax,x,ymin-(ymax-ymin)*.03,&outx,&outy);
  782.         cont(outx,outy);
  783.         transf_data(wxmin,wymin,wxmax,wymax,x,ymin-(ymax-ymin)*.035,&outx,&outy);
  784.         move(outx,outy);
  785.         sprintf(number,xformat,x);    /* put number at large tick */
  786.         label(number);
  787.     }
  788.  
  789.     labelplace("l");
  790.     y=ymin;                    /* y axis */
  791.     sprintf(number,yformat,y);        /* string rep of # */
  792.     transf_data(wxmin,wymin,wxmax,wymax,x,ymin,&outx,&outy);
  793.     move(outx,outy);
  794.     transf_data(wxmin,wymin,wxmax,wymax,xmin-(xmax-xmin)*.03,y,&outx,&outy);
  795.     cont(outx,outy);
  796.     transf_data(wxmin,wymin,wxmax,wymax,xmin-(xmax-xmin)*.035,y,&outx,&outy);
  797.     move(outx,outy);
  798.     label(number);
  799.     numlargeticks=(((ymax-ymin)/ydelta)/5);
  800.     for (i=(int)numlargeticks;i--;){
  801.         for(j=5;j--;){
  802.             transf_data(wxmin,wymin,wxmax,wymax,xmin,y,&outx,&outy);
  803.             move(outx,outy);
  804.         transf_data(wxmin,wymin,wxmax,wymax,xmin-(xmax-xmin)*.02,y,&outx,&outy);
  805.         cont(outx,outy);
  806.             y+=ydelta;
  807.         }
  808.         transf_data(wxmin,wymin,wxmax,wymax,xmin,y,&outx,&outy);
  809.         move(outx,outy);
  810.         transf_data(wxmin,wymin,wxmax,wymax,xmin-(xmax-xmin)*.03,y,&outx,&outy);
  811.         cont(outx,outy);
  812.         transf_data(wxmin,wymin,wxmax,wymax,xmin-(xmax-xmin)*.035,y,&outx,&outy);
  813.         move(outx,outy);
  814.         sprintf(number,yformat,y);
  815.         label(number);
  816.     }
  817.  
  818. }
  819. \Rogue\Monster\
  820. else
  821.   echo "will not over write ./scat.src/plttics.c"
  822. fi
  823. if `test ! -s ./scat.src/pttxt.c`
  824. then
  825. echo "writting ./scat.src/pttxt.c"
  826. cat > ./scat.src/pttxt.c << '\Rogue\Monster\'
  827. #include <stdio.h>
  828. #include "defs.h"
  829. extern int debuglevel;
  830. extern double spacekonst;
  831.  
  832. plot_texts(header,xlabel,ylabel,wxmin,wxmax,wymin,wymax,xmin,ymin,ymax)
  833. char    *header;        /* figure caption */
  834. char    *xlabel;        /* label for x axis */
  835. char    *ylabel;        /* --------- y ---- */
  836. double    xmin;        /* min of all x-values */
  837. double    ymin,ymax;        /* min of all y-values */
  838. double    wxmin,wxmax,wymin,wymax;/* window bounds */
  839. {
  840.     int outx, outy;
  841.     
  842.     if(debuglevel)fprintf(stderr,"In plot_texts\n");
  843.  
  844.     transf_data(wxmin,wymin,wxmax,wymax,(wxmin+wxmax)/2.,(wymax+ymax)/2.,&outx,&outy);
  845.     labelplace("c");
  846.     text(outx,outy,header);
  847.  
  848.     transf_data(wxmin,wymin,wxmax,wymax,(wxmin+wxmax)/2.,(wymin+ymin)/2.,&outx,&outy);
  849.     labelplace("u");
  850.     text(outx,outy,xlabel);
  851.  
  852. /*    transf_data(wxmin,wymin,wxmax,wymax,(wxmin+wxmin+wxmin+wxmin+xmin)/5.,(wymin+wymax)/2.,&outx,&outy);
  853. */
  854.     transf_data(wxmin,wymin,wxmax,wymax,(wxmin+wxmin+xmin)/3.,(wymin+wymax)/2.,&outx,&outy);
  855.     labelrotation(90);
  856.     labelplace("o");
  857.     text(outx,outy,ylabel);
  858.     labelrotation(0);
  859. }
  860. \Rogue\Monster\
  861. else
  862.   echo "will not over write ./scat.src/pttxt.c"
  863. fi
  864. if `test ! -s ./scat.src/readdat.c`
  865. then
  866. echo "writting ./scat.src/readdat.c"
  867. cat > ./scat.src/readdat.c << '\Rogue\Monster\'
  868. #include <memory.h>
  869. #include <string.h>
  870. #include <strings.h>
  871. #include "defs.h"
  872.  
  873. int     readline[]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  874. /* 1=data, 0=label-data */
  875. extern int debuglevel;
  876.  
  877. read_data(numcols,numpts,names,pnames,pcol,lnames,lcol,drawline,data
  878. ,labeldata,missingvalue)
  879.  
  880. char    names[MAXCOLS][MAXTXT];    /* input : names of columns */
  881. char    labeldata[MAXCOLS][MAXPTS][10];  /* input : label-data in columns */
  882. char    *pnames[MAXCOLS];             /* don't draw lines for columns
  883.                                         with this name */
  884. char    *lnames[MAXCOLS];             /* name of column, which has
  885.                     label-data */
  886. int    drawline[MAXCOLS];
  887. int    pcol;
  888. int    lcol;
  889. int    *numcols;
  890. int    *numpts;
  891. int    missingvalue[MAXCOLS][MAXPTS];    /* 0=value is not missing from
  892.                        input file, 1=value is missing 
  893.                        from input file */
  894. double    data[MAXCOLS][MAXPTS];    /* input : data in columns */
  895. {
  896.     int    c;        /* input character */
  897.     int    i,ii;    
  898.     int    jj;
  899.     int    col= -1;    /* running column index */
  900.     int    ldcol;    /* running column labeldata index */
  901.     int    dcol;    /* running column data index */
  902.     int    tmpcols;
  903.     int    eol=0;
  904.     int    fieldcount;
  905.     char    inputline[1024];
  906.     char    field[512];
  907.     register char    *ip;
  908.     register char    *ep;
  909.     register int    n;
  910.  
  911.     double atof();
  912.  
  913.     if (debuglevel) fprintf(stderr,"In read_data\n");
  914.     do{
  915.         i=0;
  916.         col++;
  917.         while((c=getchar())!='\t'&&c!=' '&&c!='\n'&&c!=EOF)
  918.             names[col][i++]=c;
  919.         names[col][i]='\0';
  920.     } while(c!='\n' && c!= EOF);
  921.     if(c==EOF)exit(-1);
  922.     *numcols= ++col;        /* store number of cols */
  923.     while((c=getchar())!='\n');    /* skip line of minuses */
  924.  
  925. /* put 0 in drawline, if not to draw line for this column. */
  926.     if(pcol > 0){
  927.         for(i=0; i < pcol; i++)
  928.              for(col=1;col < *numcols;col++)
  929.                                 if(!strcmp(pnames[i],names[col]))
  930.                                         drawline[col]=0;
  931.     }
  932.  
  933.     if (debuglevel) {
  934.         fprintf(stderr,"drawline after pcol\n");
  935.         for (i=0; i < *numcols; i++)
  936.             fprintf(stderr,"%d ",drawline[i]);
  937.         fprintf(stderr,"\n");
  938.     }
  939.  
  940. /* if label-column read the data in data- and labeldata-vectors */
  941.     tmpcols= *numcols;
  942.  
  943.     if(lcol > 0){
  944.         for(i=0; i < lcol; i++)
  945.              for(col=1;col < tmpcols;col++)
  946.                                 if(!strcmp(lnames[i],names[col])){
  947.                     drawline[col-1]=2;
  948.                     drawline[col]=2;
  949.                     readline[col]=0;
  950.                 }
  951.     if (debuglevel) {
  952.         fprintf(stderr,"drawline after lcol\n");
  953.         for (i=0; i < *numcols; i++)
  954.             fprintf(stderr,"%d ",drawline[i]);
  955.         fprintf(stderr,"\nreadline after lcol\n");
  956.         for (i=0; i < *numcols; i++)
  957.             fprintf(stderr,"%d ",readline[i]);
  958.         fprintf(stderr,"\n");
  959.     }
  960.  
  961. /* fix the drawline vector */
  962.          for(col=1;col<tmpcols-1;col++)
  963.             if(drawline[col] == 2 && drawline[col+1] == 2){
  964.                 for(jj=col+1; jj < tmpcols-1;jj++)
  965.                     drawline[jj]=drawline[jj+1];
  966.                 }
  967.  
  968.     if (debuglevel) {
  969.         fprintf(stderr,"drawline after fix\n");
  970.         for (i=0; i < *numcols; i++)
  971.             fprintf(stderr,"%d ",drawline[i]);
  972.         fprintf(stderr,"\n");
  973.     }
  974.         *numcols=tmpcols-lcol;
  975.         if (debuglevel) fprintf(stderr,"numcols= %d\n",*numcols);
  976.  
  977.     }
  978.     i=0;
  979.  
  980.     while(gets(inputline)) {
  981.         ip = inputline;
  982.         fieldcount = 0;
  983.             dcol=0;
  984.             ldcol=0;
  985.         col = -1;
  986.  
  987.         do {
  988.         col++;
  989.         ep = index(ip, '\t');
  990.         if (ep == 0)
  991.             n = strlen(ip);
  992.         else
  993.             n = ep - ip;
  994.         if (n > 0) {
  995.             memcpy(field, ip, n);
  996.             field[n] = '\0';
  997.  
  998.                     if(readline[col]){
  999.                         data[dcol][i]= atof(field);
  1000.             missingvalue[dcol][i]=0;
  1001.                         dcol++;
  1002.                         }
  1003.                     else{
  1004.                         strcpy(labeldata[ldcol][i],field);
  1005.                         ldcol++;
  1006.                         }
  1007.  
  1008.             }
  1009.         else{
  1010.                     if(readline[col]){
  1011.             missingvalue[dcol][i]=1;
  1012.             dcol++;
  1013.                 }
  1014.         }
  1015.         ip = ep + 1;
  1016.         } while(ep);
  1017.     i++;
  1018.     *numpts = i;
  1019.     }
  1020. }
  1021. \Rogue\Monster\
  1022. else
  1023.   echo "will not over write ./scat.src/readdat.c"
  1024. fi
  1025. if `test ! -s ./scat.src/scat.c`
  1026. then
  1027. echo "writting ./scat.src/scat.c"
  1028. cat > ./scat.src/scat.c << '\Rogue\Monster\'
  1029. #include <stdio.h>
  1030. #include "defs.h"
  1031. #define SPACECONST 1000.
  1032.  
  1033. int             drawline[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};    /* 0=no line, 1=line */
  1034.  
  1035. extern int      optind;
  1036. extern char    *optarg;
  1037. char            names[MAXCOLS][MAXTXT];    /* input : names of columns */
  1038. char            labeldata[MAXCOLS][MAXPTS][10];    /* input : label-data in
  1039.                          * columns */
  1040. char           *pnames[MAXCOLS];/* don't draw lines for columns with this
  1041.                  * name */
  1042. char           *lnames[MAXCOLS];/* name of column, which has label-data */
  1043.  
  1044. char           *optstr = "Eeicl:P:H:X:Y:F:w:x:y:d:l:L:";    /* list of options */
  1045. char           *header = "";    /* figure caption */
  1046. char           *xlabel = names[0];    /* label for x axis */
  1047. char           *ylabel = names[1];    /* --------- y ---- */
  1048. char           *plottertype = "hp300h";    /* type of output device */
  1049. char           *xformat = "%.1lf";
  1050. /* char    *yformat="%5.1lf"; */
  1051. char           *yformat = "%.1lf";
  1052. /*    "solid", "solid", "solid", "solid", "solid", /* -- was 1st line below - gs*/
  1053.  
  1054. char           *linetype[] = {
  1055.     "solid", "dotted", "longdashed", "shortdashed", "dotdashed",    /* change 14/6/89 - gs*/
  1056.     "solid", "dotted", "longdashed", "shortdashed", "dotdashed",
  1057.     "solid", "dotted", "longdashed", "shortdashed", "dotdashed",
  1058.     "solid", "dotted", "longdashed", "shortdashed", "dotdashed",
  1059.     "solid", "dotted", "longdashed", "shortdashed", "dotdashed",
  1060. };
  1061.  
  1062. static char    *help[] = {
  1063.     "Usage : scat [options]",
  1064.     "-x m,n,l    Bounds on x axis (min, max, interval   ",
  1065.     "-y m,n,l    Bounds on y axis (min, max, interval   ",
  1066.     "-w m,n,l,o    Window bounds  minx, miny, maxx,maxy   ",
  1067.     "-X text     Text for X axis                        ",
  1068.     "-Y text      Text for Y axis                        ",
  1069.     "-H text      Figurecaption                          ",
  1070.     "-F \"x/y format\"    Format for numbers on x/y axis ",
  1071.     "-c           Use colors                             ",
  1072.     "-e          No erase                               ",
  1073.     "-E          Use extended plot commands        ",
  1074.     "-l name    Name of y column not to draw lines for ",
  1075.     "-L name    Name of label-column                   ",
  1076.     "-d number    Debug level                            ",
  1077. ""};
  1078. char          **ptrhlp = help;
  1079.  
  1080. int             extended_plot = 0;
  1081.  
  1082. int             init_plotter = 1;
  1083. int             plotfil;
  1084. int             num_pens = 8;    /* number of pen in plotter */
  1085. int             numcols;    /* input : number of data-columns */
  1086. int             numpts;        /* ----------------- data pts */
  1087. int             pcol = 0;    /* number of columns, not to draw lines for */
  1088. int             lcol = 0;    /* number of label-columns in the inputdata */
  1089. int             debuglevel = 0;    /* level of debugging output */
  1090. int             outx, outy, outx1, outy1;    /* convert data to new coord.
  1091.                          * system */
  1092. int             plotdata[MAXCOLS][MAXPTS];    /* ditto  */
  1093. int             missingvalue[MAXCOLS][MAXPTS];    /* 1=value is missing from
  1094.                          * inputfile 0=value is not
  1095.                          * missing */
  1096. double          spaceconst = SPACECONST;
  1097. double          data[MAXCOLS][MAXPTS];    /* input : data in columns */
  1098. double          min[MAXCOLS];    /* min of data */
  1099. double          max[MAXCOLS];    /* max of data */
  1100. double          xmin = 0., xmax = 0.;    /* min, max of all x-values */
  1101. double          ymin = 0., ymax = 0.;    /* min, max of all y-values */
  1102. double          xdelta = 0., ydelta = 0.;    /* increment for x/y tick
  1103.                          * marks */
  1104. double          xrange = 0., yrange = 0.;    /* ranges of xy-values */
  1105. double          wxmin = 0., wxmax = 0.;    /* x-window bounds in x-scale */
  1106. double          wymin = 0., wymax = 0.;    /* y-window bounds in y-scale */
  1107. double          wx1 = 0., wx2 = SPACECONST;    /* Relative x-window bounds */
  1108. double          wy1 = 0., wy2 = SPACECONST;    /* relative y-window bounds */
  1109. main(argc, argv)
  1110.     int             argc;
  1111.     char          **argv;
  1112. {
  1113.  
  1114.     int             col, row, ldcol;    /* indices */
  1115.     int             c;
  1116.     int             werase = 1;    /* 0=no erase ; 1=erase */
  1117.     int             usecolor = 0;    /* 0=no color */
  1118.     int             optionx = 0;    /* option x not used */
  1119.     int             optiony = 0;    /* option y not used */
  1120.  
  1121.     while ((c = getopt(argc, argv, optstr)) != EOF) {
  1122.         switch (c) {
  1123.         case 'x':
  1124.             sscanf(optarg, "%lf,%lf,%lf", &xmin, &xmax, &xdelta);
  1125.             xrange = xmax - xmin;
  1126.             optionx = 1;
  1127.             break;
  1128.         case 'y':
  1129.             sscanf(optarg, "%lf,%lf,%lf", &ymin, &ymax, &ydelta);
  1130.             yrange = ymax - ymin;
  1131.             optiony = 1;
  1132.             break;
  1133.         case 'd':
  1134.             sscanf(optarg, "%d", &debuglevel);
  1135.             break;
  1136.         case 'i':
  1137.             init_plotter = 0;
  1138.             break;
  1139.         case 'E':
  1140.             extended_plot = 1;    /* no extended plot cmds */
  1141.             break;
  1142.         case 'e':
  1143.             werase = 0;    /* no erase */
  1144.             break;
  1145.         case 'c':
  1146.             usecolor = 1;    /* use color */
  1147.             break;
  1148.         case 'l':
  1149.             pnames[pcol] = optarg;
  1150.             pcol++;
  1151.             break;
  1152.         case 'L':
  1153.             lnames[lcol] = optarg;
  1154.             lcol++;
  1155.             break;
  1156.         case 'F':
  1157.             c = optarg[0];
  1158.             if (c == 'x')
  1159.                 xformat = ++optarg;
  1160.             else
  1161.                 yformat = ++optarg;
  1162.             break;
  1163.         case 'w':
  1164.             sscanf(optarg, "%lf,%lf,%lf,%lf", &wx1, &wy1, &wx2, &wy2);
  1165.             wx1 = wx1 * spaceconst;
  1166.             wx2 = wx2 * spaceconst;
  1167.             wy1 = wy1 * spaceconst;
  1168.             wy2 = wy2 * spaceconst;
  1169.             break;
  1170.         case 'X':
  1171.             xlabel = optarg;
  1172.             break;
  1173.         case 'Y':
  1174.             ylabel = optarg;
  1175.             break;
  1176.         case 'H':
  1177.             header = optarg;
  1178.             break;
  1179.         default:
  1180.             while (**ptrhlp)
  1181.                 fprintf(stderr, "\t%s\n", *ptrhlp++);
  1182.             exit(-1);
  1183.  
  1184.         }
  1185.     }
  1186.  
  1187.     if (debuglevel) {
  1188.         fprintf(stderr, "Finished reading options\n");
  1189.         fprintf(stderr, "Read data\n");
  1190.         fprintf(stderr, "pcol= %d, lcol=%d\n", pcol, lcol);
  1191.     }
  1192.     read_data(&numcols, &numpts, names, pnames, pcol, lnames, lcol, drawline,
  1193.           data, labeldata, missingvalue);
  1194.  
  1195.     if (debuglevel) {
  1196.         fprintf(stderr, "Finished reading data\n");
  1197.         for (row = 0; row < numpts; row++) {
  1198.             for (col = 0; col < lcol; col++)
  1199.                 fprintf(stderr, "%s\t", labeldata[col][row]);
  1200.             fprintf(stderr, "\n");
  1201.         }
  1202.         for (row = 0; row < numpts; row++) {
  1203.             for (col = 0; col < numcols; col++)
  1204.                 fprintf(stderr, "%lf\t", data[col][row]);
  1205.             fprintf(stderr, "\n");
  1206.         }
  1207.     }
  1208.     if (debuglevel)
  1209.         fprintf(stderr, "find min og max\n");
  1210.     /* find min and max of data */
  1211.     for (col = 0; col < numcols; col++) {
  1212.         max[col] = data[col][0];
  1213.         min[col] = data[col][0];
  1214.         for (row = 1; row < numpts; row++) {
  1215.             if (data[col][row] > max[col])
  1216.                 max[col] = data[col][row];
  1217.             else if (data[col][row] < min[col])
  1218.                 min[col] = data[col][row];
  1219.         }
  1220.     }
  1221.  
  1222.     if (optionx < 1) {
  1223.         xmin = min[0];    /* store x min and max */
  1224.         xmax = max[0];
  1225.         xrange = xmax - xmin;
  1226.         xdelta = xrange / 40.;
  1227.     }
  1228.     if (optiony < 1) {
  1229.         ymax = max[1];    /* initialize max/min of all yvals */
  1230.         ymin = min[1];
  1231.         for (col = 2; col < numcols; col++)
  1232.             if (max[col] > ymax)
  1233.                 ymax = max[col];
  1234.             else if (min[col] < ymin)
  1235.                 ymin = min[col];
  1236.         yrange = ymax - ymin;
  1237.         ydelta = yrange / 40.;
  1238.     }
  1239.     /* Enlarge outer frame */
  1240.     wxmin = xmin - 0.25 * xrange;
  1241.     wxmax = xmax + 0.10 * xrange;
  1242.     wymin = ymin - 0.25 * yrange;
  1243.     wymax = ymax + 0.15 * yrange;
  1244.  
  1245.     if (debuglevel) {
  1246.         fprintf(stderr, "wxmin= %lf and wxmax= %lf\n", wxmin, wxmax);
  1247.         fprintf(stderr, "wymin= %lf and wymax= %lf\n", wymin, wymax);
  1248.     }
  1249.     if (debuglevel)
  1250.         fprintf(stderr, "Opening plotter for output\n");
  1251.     openpl();
  1252.     if (werase)
  1253.         erase();
  1254.     space(0, 0, (int) spaceconst, (int) spaceconst);
  1255.     transf_data(wxmin, wymin, wxmax, wymax, wxmin, wymin, &outx, &outy);
  1256.     transf_data(wxmin, wymin, wxmax, wymax, wxmax, wymax, &outx1, &outy1);
  1257.     rectangle(outx, outy, outx1, outy1);
  1258.     transf_data(wxmin, wymin, wxmax, wymax, xmin, ymin, &outx, &outy);
  1259.     transf_data(wxmin, wymin, wxmax, wymax, xmax, ymax, &outx1, &outy1);
  1260.     rectangle(outx, outy, outx1, outy1);
  1261.     if (debuglevel)
  1262.         fprintf(stderr, "Finished initializing plotter\n");
  1263.  
  1264.     if (debuglevel)
  1265.         fprintf(stderr, "Converting data to new system\n");
  1266.     for (row = 0; row < numpts; row++)
  1267.         plotdata[0][row] = (int) ((wx2 - wx1) * (data[0][row] - wxmin) / (wxmax - wxmin) + wx1);
  1268.     for (col = 1; col < numcols; col++)
  1269.         for (row = 0; row < numpts; row++)
  1270.             plotdata[col][row] = (int) ((wy2 - wy1) * (data[col][row] - wymin) / (wymax - wymin) + wy1);
  1271.  
  1272.     if (debuglevel)
  1273.         fprintf(stderr, "Drawing figure\n");
  1274.     ldcol = 0;
  1275.     for (col = 1; col < numcols; col++) {
  1276.         if (usecolor)
  1277.             selectcolor((col - 1) % num_pens + 1);
  1278.         if (drawline[col] > 1) {
  1279.             labelplace("c");    /* center the label at the
  1280.                          * point */
  1281.             for (row = 0; row < numpts; row++)
  1282.                 text(plotdata[0][row], plotdata[col][row], labeldata[ldcol][row]);
  1283.             ldcol++;
  1284.         } else if (drawline[col] > 0) {
  1285.             linemod(linetype[col - 1]);
  1286.             if (!missingvalue[col][0])
  1287.                 point(plotdata[0][0], plotdata[col][0]);
  1288.             for (row = 1; row < numpts; row++) {
  1289.                 if (!missingvalue[col][row]) {
  1290.                     point(plotdata[0][row], plotdata[col][row]);
  1291.                     if (!missingvalue[col][row - 1]) {
  1292.                         move(plotdata[0][row - 1], plotdata[col][row - 1]);
  1293.                         cont(plotdata[0][row], plotdata[col][row]);
  1294.                     }
  1295.                 }
  1296.             }
  1297.         } else {
  1298.             for (row = 0; row < numpts; row++)
  1299.                 point(plotdata[0][row], plotdata[col][row]);
  1300.         }
  1301.     }
  1302.  
  1303.     if (debuglevel)
  1304.         fprintf(stderr, "Plotting tic-marks\n");
  1305.     plot_tics(wxmin, wxmax, wymin, wymax, xmin, xmax, xdelta, ymin, ymax, ydelta);
  1306.  
  1307.     if (debuglevel)
  1308.         fprintf(stderr, "Plotting texts\n");
  1309.     plot_texts(header, xlabel, ylabel, wxmin, wxmax, wymin, wymax, xmin, ymin, ymax);
  1310.  
  1311.     closepl();
  1312. }
  1313. \Rogue\Monster\
  1314. else
  1315.   echo "will not over write ./scat.src/scat.c"
  1316. fi
  1317. if `test ! -s ./scat.src/trans.c`
  1318. then
  1319. echo "writting ./scat.src/trans.c"
  1320. cat > ./scat.src/trans.c << '\Rogue\Monster\'
  1321. #include <stdio.h>
  1322. extern int debuglevel;
  1323. extern double spaceconst;
  1324. extern double wx1;
  1325. extern double wx2;
  1326. extern double wy1;
  1327. extern double wy2;
  1328.  
  1329.  
  1330. transf_data(wxmin,wymin,wxmax,wymax,inx,iny,outx,outy)
  1331. double wxmin,wymin,wxmax,wymax,inx,iny;
  1332. int   *outx,*outy;
  1333. {
  1334.   *outx=(int)((wx2-wx1)*(inx-wxmin)/(wxmax-wxmin)+wx1);
  1335.   *outy=(int)((wy2-wy1)*(iny-wymin)/(wymax-wymin)+wy1);
  1336.   if(debuglevel){
  1337.     fprintf(stderr,"inx= %lf iny= %lf\n",inx,iny);
  1338.     fprintf(stderr,"outx= %d & outy= %d\n",*outx,*outy);
  1339.   }
  1340. }
  1341.  
  1342. \Rogue\Monster\
  1343. else
  1344.   echo "will not over write ./scat.src/trans.c"
  1345. fi
  1346. if `test ! -s ./scat.src/recplot.c`
  1347. then
  1348. echo "writting ./scat.src/recplot.c"
  1349. cat > ./scat.src/recplot.c << '\Rogue\Monster\'
  1350. /* recplot.c -- some general routines for plotting 
  1351.  
  1352. Currently this is quite poor - only rectangle and text.
  1353. Someone should add higher-level routines, but of course these
  1354. can only be allowed to call the plot(3)-library (possibly with
  1355. extensions, which should then be placed in extplotlib.c, and
  1356. device-specific versions should be placed in the device-specific filters
  1357. (such as the enclosed hpglplot.c and xplot.c)
  1358.  
  1359. */
  1360. #include <stdio.h>
  1361. extern int debuglevel;
  1362. extern int extended_plot;
  1363.  
  1364.  
  1365. rectangle(x,y,u,w)
  1366. int x,y,u,w;
  1367. {
  1368.     move(x,y);
  1369.     cont(x,w);
  1370.     cont(u,w);
  1371.     cont(u,y);
  1372.     cont(x,y);
  1373. }
  1374. text(x,y,labl)
  1375. int x,y;
  1376. char *labl;
  1377. {
  1378.     move(x,y);
  1379.     label(labl);
  1380. }
  1381. \Rogue\Monster\
  1382. else
  1383.   echo "will not over write ./scat.src/recplot.c"
  1384. fi
  1385. if `test ! -s ./scat.src/extplotlib.c`
  1386. then
  1387. echo "writting ./scat.src/extplotlib.c"
  1388. cat > ./scat.src/extplotlib.c << '\Rogue\Monster\'
  1389. /* extplotlib.c -- extensions to the plot-library
  1390.                    these routine generate plot(5) output
  1391.                    When linking directly to a device library (e.g. hpglplot.o),
  1392.                    which has the device-dependent version of
  1393.            these routines, this should not be included.
  1394. */
  1395. #include <stdio.h>
  1396. extern int debuglevel;
  1397. extern int extended_plot;
  1398.  
  1399.  
  1400. labelrotation(x)
  1401. int x;
  1402. {
  1403.     if(extended_plot){
  1404.         if (x == 90)
  1405.             printf("r v\n");      /* vertical */
  1406.         else
  1407.             printf("r h\n");    /* horizontal */
  1408.     }
  1409. }
  1410. labelplace(s)
  1411. char *s;
  1412. {
  1413.     if(extended_plot){
  1414.         printf("u %s\n",s);
  1415.     }
  1416. }
  1417. selectcolor(x)
  1418. int x;
  1419. {
  1420.     if(extended_plot){
  1421.         printf("z %d\n",x);
  1422.     }
  1423. }
  1424.  
  1425. \Rogue\Monster\
  1426. else
  1427.   echo "will not over write ./scat.src/extplotlib.c"
  1428. fi
  1429. if `test ! -s ./scat.src/scat.starbase.c`
  1430. then
  1431. echo "writting ./scat.src/scat.starbase.c"
  1432. cat > ./scat.src/scat.starbase.c << '\Rogue\Monster\'
  1433. #include <stdio.h>
  1434. #include <starbase.c.h>
  1435.  
  1436. #define MAXPTS    1500    /* max no of data points (lines in file) */
  1437. #define MAXCOLS    25    /* max no of data columns */
  1438. #define MAXTXT    100    /* max length of name of column */
  1439. int    drawline[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 0=no line, 1=line */
  1440.  
  1441. extern char *optarg;
  1442.  
  1443. main(argc,argv)
  1444. int    argc;
  1445. char    **argv;
  1446. {
  1447.     char    names[MAXCOLS][MAXTXT];    /* input : names of columns */
  1448.     char    *optstr="eicl:P:D:H:X:Y:w:x:y:";    /* list of options */
  1449.     char    *header="";        /* figure caption */
  1450.     char    *xlabel=names[0];    /* label for x axis */
  1451.     char    *ylabel=names[1];    /* --------- y ---- */
  1452.     char    *device="/dev/crt";    /* output device (/dev entry) */
  1453.     char    *plottertype="hp300h";    /* type of output device */
  1454.     static char    *help[]={
  1455.         "Usage : scat [options]",
  1456.         "-x m,n,l    Bounds on x axis (min, max, interval   ",
  1457.         "-y m,n,l    Bounds on y axis (min, max, interval   ",
  1458.         "-w m,n,l,o    Window bounds  minx, miny, maxx,maxy   ",
  1459.         "-X text     Text for X axis                        ",
  1460.         "-Y text      Text for Y axis                        ",
  1461.         "-H text      Figurecaption                          ",
  1462.         "-P plottertype    Type of plotter (e.g. hp2622 og hpgl)  ",
  1463.         "-D device    Device (e.g. filename or /dev/plt7550) ",
  1464.         "-c           Use colors                             ",
  1465.         "-i           Don't initialize plotter               ",
  1466.         "-e          No erase                               ",
  1467.         "-l name    Name of y column to draw lines for     ",
  1468.         ""};
  1469.         char    **ptrhlp=help;
  1470.  
  1471.     int    init_plotter=INIT;
  1472.     int    plotfil;
  1473.     int    numcols;        /* input : number of columns */
  1474.     int    numpts;            /* ----------------- data pts */
  1475.     int    col,row;        /* indices */
  1476.     int    c;
  1477.     int    num_pts,y,yy;        /* */
  1478.     int    num_pens;
  1479.     int    werase=1;        /* 0=no erase ; 1=erase */
  1480.     int    usecolor=0;        /* 0=no color */
  1481.  
  1482.     float    plotvec[MAXPTS*2];    /* temp vec for plotting */
  1483.     float    ph_lim[2][3],res[3],p1[3],p2[3];
  1484.  
  1485.     double    data[MAXCOLS][MAXPTS];    /* input : data in columns */
  1486.     double    min[MAXCOLS];        /* min of data */
  1487.     double    max[MAXCOLS];        /* max of data */
  1488.     double    xmin,xmax;        /* min, max of all x-values */
  1489.     double    ymin,ymax;        /* min, max of all y-values */
  1490.     double    xdelta=0.,ydelta=0.;    /* increment for x/y tick marks */
  1491.     double    xrange=0.,yrange=0.;    /* ranges of xy-values */
  1492.     double    wxmin=0.,wxmax= 0.;    /* x-window bounds in x-scale */
  1493.     double    wymin=0.,wymax= 0.;    /* y-window bounds in y-scale */
  1494.     float    wx1=0., wx2=1.;        /* Relative x-window bounds */
  1495.     float    wy1=0., wy2=1.;        /* relative y-window bounds */
  1496.  
  1497.  
  1498.     read_data(&numcols,&numpts,names,data);
  1499.     find_bounds(numcols,numpts,data,min,max,&xmin,&xmax,&ymin,&ymax);
  1500.     
  1501.     xrange=xmax-xmin;
  1502.     xdelta=xrange/40.;
  1503.     yrange=ymax-ymin;
  1504.     ydelta=yrange/40.;
  1505.     while ((c = getopt(argc, argv, optstr)) != EOF) {
  1506.         switch ( c ) {
  1507.         case 'x': sscanf(optarg,"%lf,%lf,%lf",&xmin,&xmax,&xdelta);
  1508.             xrange=xmax-xmin;
  1509.              break; 
  1510.         case 'y': sscanf(optarg,"%lf,%lf,%lf",&ymin,&ymax,&ydelta);
  1511.             yrange=ymax-ymin;
  1512.              break; 
  1513.         case 'i': init_plotter=SPOOLED;
  1514.             break;
  1515.         case 'e': werase=0;        /* no erase */
  1516.             break;
  1517.         case 'c': usecolor=1;        /* use color */
  1518.             break;
  1519.         case 'l': for(col=1;col<numcols;col++)
  1520.                 if(!strcmp(optarg,names[col]))
  1521.                     drawline[col]=1;
  1522.         case 'w': sscanf(optarg,"%f,%f,%f,%f", &wx1,&wy1,&wx2,&wy2);
  1523.              break; 
  1524.         case 'X': xlabel = optarg;         break; 
  1525.         case 'Y': ylabel = optarg;        break;
  1526.         case 'H': header = optarg;        break;
  1527.         case 'D': device = optarg;        break;
  1528.         case 'P': plottertype = optarg;        break;
  1529.         default:
  1530.             while(**ptrhlp)fprintf(stderr,"\t%s\n",*ptrhlp++);
  1531.             exit(-1);
  1532.  
  1533.         }
  1534.     }
  1535.  
  1536.     wxmin=xmin-0.25*xrange;
  1537.     wxmax=xmax+0.05*xrange;
  1538.     wymin=ymin-0.25*yrange;
  1539.     wymax=ymax+0.15*yrange;
  1540.  
  1541.     if((plotfil=gopen(device,OUTDEV,plottertype,init_plotter))== -1)exit(-1);
  1542.     set_p1_p2(plotfil,FRACTIONAL,wx1,wy1,0.,wx2,wy2,0.);
  1543.     vdc_extent(plotfil,(float)wxmin,(float)wymin,(float)0.,(float)wxmax,(float)wymax,(float)0.);
  1544.     clip_rectangle(plotfil,(float)wxmin,(float)wxmax,(float)wymin,(float)wymax);
  1545.     mapping_mode(plotfil,TRUE);
  1546.     interior_style(plotfil,INT_HOLLOW,TRUE);
  1547.     rectangle(plotfil,(float)wxmin,(float)wymin,(float)wxmax,(float)wymax);
  1548.     rectangle(plotfil,(float)xmin,(float)ymin,(float)xmax,(float)ymax);
  1549.  
  1550.     inquire_sizes(plotfil,ph_lim,res,p1,p2,&num_pens);
  1551.     for(col=1;col<numcols;col++){
  1552.         for(row=0;row<numpts;row++){
  1553.             plotvec[2*row]=data[0][row];
  1554.             plotvec[2*row+1]=data[col][row];
  1555.         }
  1556.         y=col+1;
  1557.         yy=col-1;
  1558.         if(usecolor)
  1559.             line_color_index(plotfil,y%num_pens);
  1560.         else
  1561.             line_type(plotfil,yy%7);
  1562.         if(drawline[col]) 
  1563.             polymarker2d(plotfil,plotvec,numpts,FALSE);
  1564.         else
  1565.             polyline2d(plotfil,plotvec,numpts,FALSE);
  1566.     }
  1567.     line_color_index(plotfil,1);
  1568.     plot_texts(plotfil,header,xlabel,ylabel,wxmin,wxmax,wymin,wymax,xmin,xmax,ymin,ymax);
  1569.  
  1570.     line_color_index(plotfil,1);
  1571.     plot_tics(plotfil,xmin,xmax,xdelta,ymin,ymax,ydelta,wxmin,wxmax,wymin,wymax);
  1572.  
  1573.     gclose(plotfil);
  1574. }
  1575. read_data(numcols,numpts,names,data)
  1576. char    names[MAXCOLS][MAXTXT];    /* input : names of columns */
  1577. int    *numcols;
  1578. int    *numpts;
  1579. double    data[MAXCOLS][MAXPTS];    /* input : data in columns */
  1580. {
  1581.     int    c;        /* input character */
  1582.     int    i;    
  1583.     int    col= -1;    /* running column index */
  1584.  
  1585.     do{
  1586.         i=0;
  1587.         col++;
  1588.         while((c=getchar())!='\t'&&c!=' '&&c!='\n'&&c!=EOF)
  1589.             names[col][i++]=c;
  1590.         names[col][i]='\0';
  1591.     } while(c!='\n' && c!= EOF);
  1592.     if(c==EOF)exit(-1);
  1593.     *numcols= ++col;        /* store number of cols */
  1594.     while((c=getchar())!='\n');    /* skip line of minuses */
  1595.     i=0;
  1596.     do {
  1597.         for(col=0;col < *numcols ; col++)
  1598.             if(scanf("%lf",&data[col][i])<=0)return;
  1599.         i++;
  1600.         *numpts=i;
  1601.     } while(1);
  1602. }
  1603. find_bounds(numcols,numpts,data,min,max,xmin,xmax,ymin,ymax)
  1604. int    numcols;        /* input : number of columns */
  1605. int    numpts;            /* ----------------- data pts */
  1606. double    data[MAXCOLS][MAXPTS];    /* input : data in columns */
  1607. double    min[MAXCOLS];    /* min on data */
  1608. double    max[MAXCOLS];    /* max of data */
  1609. double    *xmin,*xmax;    /* min,max of ALL x-values */
  1610. double    *ymin,*ymax;    /* min,max of ALL y-values */
  1611. {
  1612.     int    col;
  1613.     int    row;
  1614.     for(col=0;col<numcols;col++){
  1615.         max[col]=data[col][0];
  1616.         min[col]=data[col][0];
  1617.         for(row=1;row<numpts;row++){
  1618.             if(data[col][row]>max[col])
  1619.                 max[col]=data[col][row];
  1620.             else if(data[col][row]<min[col])
  1621.                 min[col]=data[col][row];
  1622.         }
  1623.     }
  1624.     *ymax=max[1];            /* initialize max/min of all y vals */
  1625.     *ymin=min[1];
  1626.     for(col=2;col<numcols;col++)
  1627.         if(max[col]>*ymax)*ymax=max[col];
  1628.         else if(min[col]<*ymin)*ymin=min[col];
  1629.     *xmin=min[0];            /* store x min and max */
  1630.     *xmax=max[0];
  1631. }
  1632. plot_texts(plotfil,header,xlabel,ylabel,wxmin,wxmax,wymin,wymax,xmin,xmax,ymin,ymax)
  1633. int    plotfil;
  1634. char    *header;        /* figure caption */
  1635. char    *xlabel;        /* label for x axis */
  1636. char    *ylabel;        /* --------- y ---- */
  1637. double    xmin,xmax;        /* min, max of all x-values */
  1638. double    ymin,ymax;        /* min, max of all y-values */
  1639. double    wxmin,wxmax,wymin,wymax;/* window bounds */
  1640. {
  1641.     text_alignment(plotfil,TA_CENTER,TA_TOP,0.0,0.0);    /* header */
  1642.     character_height(plotfil,.04*(wymax-wymin));
  1643.     text2d(plotfil,(wxmin+wxmax)/2.,wymax,
  1644.         header,VDC_TEXT,FALSE);
  1645.     text_alignment(plotfil,TA_CENTER,TA_TOP,0.0,0.0);    /* x-axis */
  1646.     character_height(plotfil,.04*(wymax-wymin));
  1647.     text2d(plotfil,(float)(wxmin+wxmax)/2.,(float)(wymin+ymin)/2.,
  1648.         xlabel,VDC_TEXT,FALSE);
  1649.     text_path(plotfil,PATH_DOWN);            /* y-axis */
  1650.     text_alignment(plotfil,TA_CENTER,TA_HALF,0.,0.);
  1651.     character_height(plotfil,.04*(wymax-wymin));
  1652.     text2d(plotfil,(wxmin+wxmin+xmin)/3.,(wymin+wymax)/2.,
  1653.         ylabel,VDC_TEXT,FALSE);
  1654. }
  1655. plot_tics(plotfil,xmin,xmax,xdelta,ymin,ymax,ydelta,wxmin,wxmax,wymin,wymax)
  1656. int    plotfil;
  1657. double    xmin,xmax;        /* min, max of all x-values */
  1658. double    ymin,ymax;        /* min, max of all y-values */
  1659. double    xdelta,ydelta;        /* increment for x/y tick marks */
  1660. double    wxmin,wxmax,wymin,wymax;/* window bounds */
  1661. {
  1662.     int i=0,j=0;
  1663.     char number[80];
  1664.     float numlargeticks;
  1665.     float x, y;
  1666.  
  1667.     text_path(plotfil,PATH_RIGHT);
  1668.     text_alignment(plotfil,TA_CENTER,TA_CONTINUOUS_VERTICAL,0.0,1.2);
  1669.     character_height(plotfil,.03*(wymax-wymin));
  1670.     line_type(plotfil,0);
  1671.     
  1672.     x=xmin;                /* x axis */
  1673.     sprintf(number,"%5.1lf",x);    /* char version of axis number */
  1674.     text2d(plotfil,x,ymin,number,VDC_TEXT,FALSE);
  1675.     numlargeticks=(((xmax-xmin)/xdelta)/5);
  1676.     for(i=numlargeticks;i--;){    /* large tick loop */
  1677.         for(j=5;j--;){        /* small tick loop */
  1678.             move2d(plotfil,x,ymin);    /* draw small tick */
  1679.             draw2d(plotfil,x,ymin+((ymax-ymin)*.015));
  1680.             x+=xdelta;        /* x for next small tick */
  1681.         }
  1682.         move2d(plotfil,x,ymin);        /* next large tick */
  1683.         draw2d(plotfil,x,ymin+((ymax-ymin)*.03));
  1684.         sprintf(number,"%5.1lf",x);    /* put number at large tick */
  1685.         text2d(plotfil,x,ymin,number,VDC_TEXT,FALSE);
  1686.     }
  1687.     text_alignment(plotfil,TA_CONTINUOUS_HORIZONTAL,TA_HALF,1.2,0.0);
  1688.     y=ymin;                    /* y axis */
  1689.     sprintf(number,"%5.1lf",y);        /* string rep of # */
  1690.     text2d(plotfil,xmin,y,number,VDC_TEXT,FALSE);
  1691.     numlargeticks=(((ymax-ymin)/ydelta)/5);
  1692.     for (i=numlargeticks;i--;){
  1693.         for(j=5;j--;){
  1694.             move2d(plotfil,xmin,y);
  1695.             draw2d(plotfil,xmin+(xmax-xmin)*.02,y);
  1696.             y+=ydelta;
  1697.         }
  1698.         move2d(plotfil,xmin,y);
  1699.         draw2d(plotfil,xmin+(xmax-xmin)*.03,y);
  1700.         sprintf(number,"%5.1lf",y);
  1701.         text2d(plotfil,xmin,y,number,VDC_TEXT,FALSE);
  1702.     }
  1703. }
  1704.  
  1705.  
  1706.  
  1707. \Rogue\Monster\
  1708. else
  1709.   echo "will not over write ./scat.src/scat.starbase.c"
  1710. fi
  1711. if `test ! -d ./testdb`
  1712. then
  1713.   mkdir ./testdb
  1714.   echo "mkdir ./testdb"
  1715. fi
  1716. if `test ! -s ./testdb/data`
  1717. then
  1718. echo "writting ./testdb/data"
  1719. cat > ./testdb/data << '\Rogue\Monster\'
  1720. x    y    z    v    u    w    i
  1721. -    -    -    -    -    -    -
  1722. 0    1    2    3    4    *    6
  1723. 1    2    3    4    5    **    7
  1724. 2    3    4    5    6    ***    8
  1725. 3    4    5    6    7    v    9
  1726. 4    5    6    7    8    vi    10
  1727. \Rogue\Monster\
  1728. else
  1729.   echo "will not over write ./testdb/data"
  1730. fi
  1731. if `test ! -s ./testdb/data.addcol`
  1732. then
  1733. echo "writting ./testdb/data.addcol"
  1734. cat > ./testdb/data.addcol << '\Rogue\Monster\'
  1735. x    y    z    v    u    w    i
  1736. -    -    -    -    -    -    -
  1737. 0    1    2    3    4    *    6
  1738. 1    2    3    4    5    **    7
  1739. 2    3    4    5    6    ***    8
  1740. 3    4    5    6    7    v    9
  1741. 4    5    6    7    8    vi    10
  1742. \Rogue\Monster\
  1743. else
  1744.   echo "will not over write ./testdb/data.addcol"
  1745. fi
  1746. if `test ! -s ./testdb/subtotal.prog`
  1747. then
  1748. echo "writting ./testdb/subtotal.prog"
  1749. cat > ./testdb/subtotal.prog << '\Rogue\Monster\'
  1750. #!/bin/sh
  1751. #
  1752. # Shell script to test subtotal reldb program.
  1753. #
  1754. # Note that this also requires project and sorttable to work.
  1755. #
  1756. BINDIR=$1
  1757. INPUTFILE=$2
  1758. PATH=$BINDIR:$PATH
  1759. export PATH
  1760.  
  1761. # Test1 -- very simple test
  1762.  
  1763. COMMAND=subtotal
  1764. ARG1='w'
  1765. ARG2='y'
  1766. ARG="by $ARG1 on $ARG2"
  1767.  
  1768. echo ; echo "Input data ($INPUTFILE):" ; echo
  1769. cat $INPUTFILE
  1770.  
  1771. echo;echo The following is the output from the command
  1772. echo "$COMMAND $ARG < $INPUTFILE"
  1773. echo
  1774. $COMMAND $ARG < $INPUTFILE
  1775. COMMAND=subtotal
  1776. ARG1='y z'
  1777. ARG2='u w v'
  1778. ARG="by $ARG1 on $ARG2"
  1779.  
  1780. echo ' '; echo "Input data ($INPUTFILE):" ; echo
  1781. cat $INPUTFILE
  1782.  
  1783. echo;echo The following is the output from the command
  1784. echo "$COMMAND $ARG < $INPUTFILE"
  1785. echo
  1786. $COMMAND $ARG < $INPUTFILE
  1787.  
  1788. echo "Note that the input is not automatically sorted by
  1789. $COMMAND - however, the project command is run first, to reorder
  1790. the columns. To see explicitly how '$COMMAND $ARG' works, here 
  1791. is the output of 'project $ARG1 $ARG2 < $INPUTFILE' :"
  1792.  
  1793. project $ARG1 $ARG2 < $INPUTFILE
  1794. \Rogue\Monster\
  1795. else
  1796.   echo "will not over write ./testdb/subtotal.prog"
  1797. fi
  1798. if `test ! -s ./testdb/union.res`
  1799. then
  1800. echo "writting ./testdb/union.res"
  1801. cat > ./testdb/union.res << '\Rogue\Monster\'
  1802. The union takes two input files, e.g.
  1803. union.dat1:
  1804. col1    col2    col3
  1805. ----    ----    ----
  1806. this    is    line1
  1807. line2    in    file1
  1808. line3    x    x
  1809. and union.dat2:
  1810. col1    col2    col3
  1811. ----    ----    ----
  1812. this is    line1    in file2
  1813. line2    in    file2
  1814.  
  1815. The following is the output from the command
  1816. union union.dat1 union.dat2
  1817.  
  1818. col1    col2    col3
  1819. ----    ----    ----
  1820. this    is    line1
  1821. line2    in    file1
  1822. line3    x    x
  1823. this is    line1    in file2
  1824. line2    in    file2
  1825. \Rogue\Monster\
  1826. else
  1827.   echo "will not over write ./testdb/union.res"
  1828. fi
  1829. if `test ! -s ./testdb/addcol.data`
  1830. then
  1831. echo "writting ./testdb/addcol.data"
  1832. cat > ./testdb/addcol.data << '\Rogue\Monster\'
  1833. x    y    z    v    u
  1834. -    -    -    -    -
  1835. 0    9    2    3    4
  1836. 1    2    2    3    4
  1837. 2    3    4    5    6
  1838. 2    3    5    6    7
  1839. 4    5    6    7    8
  1840. \Rogue\Monster\
  1841. else
  1842.   echo "will not over write ./testdb/addcol.data"
  1843. fi
  1844. if `test ! -s ./testdb/compute.data`
  1845. then
  1846. echo "writting ./testdb/compute.data"
  1847. cat > ./testdb/compute.data << '\Rogue\Monster\'
  1848. x    y    z    v    u    w    i
  1849. -    -    -    -    -    -    -
  1850. 0    1    2    3    4    *    6
  1851. 1    2    3    4    5    **    7
  1852. 2    3    4    5    6    ***    8
  1853. 3    4    5    6    7    v    9
  1854. 4    5    6    7    8    vi    10
  1855. \Rogue\Monster\
  1856. else
  1857.   echo "will not over write ./testdb/compute.data"
  1858. fi
  1859. if `test ! -s ./testdb/select.data`
  1860. then
  1861. echo "writting ./testdb/select.data"
  1862. cat > ./testdb/select.data << '\Rogue\Monster\'
  1863. x    y    z    v    u    w    i
  1864. -    -    -    -    -    -    -
  1865. 0    2    2    3    4    text1    6
  1866. 5    1    2    3    4    text2    6
  1867. 4    1    2    3    4    text3    6
  1868. 1    2    3    4    5    **    7
  1869. 2    3    4    5    6    ***    8
  1870. 3    4    5    6    7    v    9
  1871. 4    5    6    7    8    vi    10
  1872. \Rogue\Monster\
  1873. else
  1874.   echo "will not over write ./testdb/select.data"
  1875. fi
  1876. if `test ! -s ./testdb/Makefile`
  1877. then
  1878. echo "writting ./testdb/Makefile"
  1879. cat > ./testdb/Makefile << '\Rogue\Monster\'
  1880. #
  1881. # Makefile to control testing of reldb programs.
  1882. #
  1883. # Change the BINDIR to reflect where the binaries are.
  1884. #
  1885. BINDIR=../bin
  1886. SUFFIXES=.diff .tmp .data .res
  1887. .SUFFIXES: $(SUFFIXES)
  1888. DIFFFILES=subtotal.diff addcol.diff compute.diff \
  1889.     jointable.diff  math.diff \
  1890.     project.diff select.diff union.diff recode.diff
  1891. .data.diff:
  1892.     $*.prog $(BINDIR) $*.data > $*.tmp
  1893.     -diff $*.tmp $*.res > $*.diff
  1894. all: $(DIFFFILES)
  1895.     @echo Done - check if any .diff-files are nonempty
  1896.     @ls -l $(DIFFFILES)
  1897. clean: 
  1898.     rm -f *.diff *.tmp tmp*
  1899. \Rogue\Monster\
  1900. else
  1901.   echo "will not over write ./testdb/Makefile"
  1902. fi
  1903. if `test ! -s ./testdb/addcol.prog`
  1904. then
  1905. echo "writting ./testdb/addcol.prog"
  1906. cat > ./testdb/addcol.prog << '\Rogue\Monster\'
  1907. #!/bin/sh
  1908. #
  1909. # Shell script to test addcol reldb program.
  1910. #
  1911. BINDIR=$1
  1912. INPUTFILE=$2
  1913. PATH=$PATH:$BINDIR
  1914. export PATH
  1915.  
  1916. # Real simple - just add two columns
  1917. COMMAND="addcol www zzz" 
  1918. echo ; echo "Input data (file $INPUTFILE)" ; echo
  1919. cat $INPUTFILE
  1920. echo;echo The following is the output from the command
  1921. echo "$COMMAND < $INPUTFILE"
  1922. echo
  1923. $COMMAND < $INPUTFILE
  1924. \Rogue\Monster\
  1925. else
  1926.   echo "will not over write ./testdb/addcol.prog"
  1927. fi
  1928. if `test ! -s ./testdb/project.data`
  1929. then
  1930. echo "writting ./testdb/project.data"
  1931. cat > ./testdb/project.data << '\Rogue\Monster\'
  1932. x    y    z    v    u    i    label_column
  1933. -    -    -    -    -    -    ------------
  1934. 0    1    2    3    4    6    *
  1935. 1    2    3    4    5    7    **
  1936. 2    3    4    5    6    8    ***
  1937. 3    4    5    6    7    9    v
  1938. 4    5    6    7    8    10    vi
  1939. \Rogue\Monster\
  1940. else
  1941.   echo "will not over write ./testdb/project.data"
  1942. fi
  1943. if `test ! -s ./testdb/subtotal.data`
  1944. then
  1945. echo "writting ./testdb/subtotal.data"
  1946. cat > ./testdb/subtotal.data << '\Rogue\Monster\'
  1947. ex1    w    y    z    v    u    extra
  1948. ---    -    -    -    -    -    -----
  1949. 25    0    9    2    3    4    -3
  1950. 4    0    2    2    3    4    -2
  1951. 5    0    3    4    5    6    -3
  1952. 5    2    3    4    6    7    -4
  1953. 9    2    5    6    7    10    -3
  1954. 9    2    5    6    120    8    -116
  1955. 9    23    5    6    7    8    16
  1956. 25    0    9    2    3    4    -3
  1957. 25    2    9    2    5    6    -3
  1958. \Rogue\Monster\
  1959. else
  1960.   echo "will not over write ./testdb/subtotal.data"
  1961. fi
  1962. if `test ! -s ./testdb/compute.res`
  1963. then
  1964. echo "writting ./testdb/compute.res"
  1965. cat > ./testdb/compute.res << '\Rogue\Monster\'
  1966.  
  1967. Input data (compute.data):
  1968.  
  1969. x    y    z    v    u    w    i
  1970. -    -    -    -    -    -    -
  1971. 0    1    2    3    4    *    6
  1972. 1    2    3    4    5    **    7
  1973. 2    3    4    5    6    ***    8
  1974. 3    4    5    6    7    v    9
  1975. 4    5    6    7    8    vi    10
  1976.  
  1977. The following is the output from the command
  1978. compute 'w=1;y=2*i;x=sqrt(i*z)' < compute.data
  1979.  
  1980. x    y    z    v    u    w    i
  1981. -    -    -    -    -    -    -
  1982. 3.4641    12    2    3    4    1    6
  1983. 4.58258    14    3    4    5    1    7
  1984. 5.65685    16    4    5    6    1    8
  1985. 6.7082    18    5    6    7    1    9
  1986. 7.74597    20    6    7    8    1    10
  1987. \Rogue\Monster\
  1988. else
  1989.   echo "will not over write ./testdb/compute.res"
  1990. fi
  1991. if `test ! -s ./testdb/project.prog`
  1992. then
  1993. echo "writting ./testdb/project.prog"
  1994. cat > ./testdb/project.prog << '\Rogue\Monster\'
  1995. #!/bin/sh
  1996. #
  1997. # Shell script to test project reldb program.
  1998. #
  1999. BINDIR=$1
  2000. INPUTFILE=$2
  2001. PATH=$PATH:$BINDIR
  2002. export PATH
  2003. #Test project command
  2004. ARG="y z i label_column v"
  2005. set - $ARG
  2006.  
  2007.  
  2008. COMMAND=project
  2009. echo ; echo "Input data ($INPUTFILE):" ; echo
  2010. cat $INPUTFILE
  2011. echo "(Note that the columns will not align on the screen when
  2012. a an entry is wider than 8 characters. This is OK since the delimiter
  2013. between fields is a single TAB character in all cases)"
  2014. echo;echo The following is the output from the command
  2015. echo "$COMMAND $* < $INPUTFILE"
  2016. echo
  2017. $COMMAND $* < $INPUTFILE
  2018. \Rogue\Monster\
  2019. else
  2020.   echo "will not over write ./testdb/project.prog"
  2021. fi
  2022. if `test ! -s ./testdb/compute.prog`
  2023. then
  2024. echo "writting ./testdb/compute.prog"
  2025. cat > ./testdb/compute.prog << '\Rogue\Monster\'
  2026. #!/bin/sh
  2027. #
  2028. # Shell script to test compute reldb program.
  2029. #
  2030. BINDIR=$1
  2031. INPUTFILE=$2
  2032. PATH=$PATH:$BINDIR
  2033. export PATH
  2034. #Test compute command
  2035. #
  2036. COMMAND=compute
  2037. ARG='w=1;y=2*i;x=sqrt(i*z)'
  2038. echo ; echo "Input data ($INPUTFILE):" ; echo
  2039. cat $INPUTFILE
  2040. echo;echo The following is the output from the command
  2041. echo "$COMMAND '$ARG' < $INPUTFILE"
  2042. echo
  2043. $COMMAND $ARG < $INPUTFILE
  2044. \Rogue\Monster\
  2045. else
  2046.   echo "will not over write ./testdb/compute.prog"
  2047. fi
  2048. if `test ! -s ./testdb/project.res`
  2049. then
  2050. echo "writting ./testdb/project.res"
  2051. cat > ./testdb/project.res << '\Rogue\Monster\'
  2052.  
  2053. Input data (project.data):
  2054.  
  2055. x    y    z    v    u    i    label_column
  2056. -    -    -    -    -    -    ------------
  2057. 0    1    2    3    4    6    *
  2058. 1    2    3    4    5    7    **
  2059. 2    3    4    5    6    8    ***
  2060. 3    4    5    6    7    9    v
  2061. 4    5    6    7    8    10    vi
  2062. (Note that the columns will not align on the screen when
  2063. a an entry is wider than 8 characters. This is OK since the delimiter
  2064. between fields is a single TAB character in all cases)
  2065.  
  2066. The following is the output from the command
  2067. project y z i label_column v < project.data
  2068.  
  2069. y    z    i    label_column    v
  2070. -    -    -    ------------    -
  2071. 1    2    6    *    3
  2072. 2    3    7    **    4
  2073. 3    4    8    ***    5
  2074. 4    5    9    v    6
  2075. 5    6    10    vi    7
  2076. \Rogue\Monster\
  2077. else
  2078.   echo "will not over write ./testdb/project.res"
  2079. fi
  2080. if `test ! -s ./testdb/jointable.prog`
  2081. then
  2082. echo "writting ./testdb/jointable.prog"
  2083. cat > ./testdb/jointable.prog << '\Rogue\Monster\'
  2084. #!/bin/sh
  2085. #
  2086. # Shell script to test jointable reldb program.
  2087. #
  2088. # Note that jointable requires two input files - this
  2089. # cannot be handled by the Makefile, so we simply ignore
  2090. # the files the Makefile gives us.
  2091. #
  2092. BINDIR=$1
  2093. INPUTFILE=$2
  2094. PATH=$PATH:$BINDIR
  2095. export PATH
  2096. #Test jointable command --  note that this requires sorttable to work also.
  2097. #echo Sorting file join.dat1
  2098. #sorttable < join.dat1 > tmp.joint.1
  2099. #sorttable < join.dat2 > tmp.joint.2
  2100. #echo Joining results of sort to get joined output:
  2101. #jointable tmp.joint.1 tmp.joint.2 
  2102. #rm tmp.joint.1 tmp.joint.2
  2103.  
  2104. COMMAND=sorttable
  2105. INPUTFILE=join.dat1
  2106. OUTPUTFILE=tmp.joint.1
  2107. echo ; echo "Input data ($INPUTFILE):" ; echo
  2108. cat $INPUTFILE
  2109. echo;echo The following is the output from the command
  2110. echo "$COMMAND  < $INPUTFILE > $OUTPUTFILE"
  2111. echo
  2112. $COMMAND $ARG < $INPUTFILE > $OUTPUTFILE
  2113. cat $OUTPUTFILE
  2114.  
  2115. COMMAND=sorttable
  2116. INPUTFILE=join.dat2
  2117. OUTPUTFILE=tmp.joint.2
  2118. echo ; echo "Input data ($INPUTFILE):" ; echo
  2119. cat $INPUTFILE
  2120. echo;echo The following is the output from the command
  2121. echo "$COMMAND  < $INPUTFILE > $OUTPUTFILE"
  2122. echo
  2123. $COMMAND $ARG < $INPUTFILE > $OUTPUTFILE
  2124. cat $OUTPUTFILE
  2125.  
  2126. COMMAND=jointable
  2127. FILE1=tmp.joint.1
  2128. FILE2=tmp.joint.2
  2129. echo;echo The following is the output from the command
  2130. echo "$COMMAND $FILE1 $FILE2"
  2131. echo
  2132. $COMMAND $FILE1 $FILE2
  2133.  
  2134. rm tmp.joint.1 tmp.joint.2
  2135. \Rogue\Monster\
  2136. else
  2137.   echo "will not over write ./testdb/jointable.prog"
  2138. fi
  2139. if `test ! -s ./testdb/select.res`
  2140. then
  2141. echo "writting ./testdb/select.res"
  2142. cat > ./testdb/select.res << '\Rogue\Monster\'
  2143.  
  2144. Input data (select.data):
  2145.  
  2146. x    y    z    v    u    w    i
  2147. -    -    -    -    -    -    -
  2148. 0    2    2    3    4    text1    6
  2149. 5    1    2    3    4    text2    6
  2150. 4    1    2    3    4    text3    6
  2151. 1    2    3    4    5    **    7
  2152. 2    3    4    5    6    ***    8
  2153. 3    4    5    6    7    v    9
  2154. 4    5    6    7    8    vi    10
  2155.  
  2156. The following is the output from the command
  2157. select 'z>=3||y==2' < select.data
  2158.  
  2159. x    y    z    v    u    w    i
  2160. -    -    -    -    -    -    -
  2161. 0    2    2    3    4    text1    6
  2162. 1    2    3    4    5    **    7
  2163. 2    3    4    5    6    ***    8
  2164. 3    4    5    6    7    v    9
  2165. 4    5    6    7    8    vi    10
  2166. (The above select-command selects those lines in the
  2167. input file where either z is greater-than-or-equal-to 3 or
  2168. y is equal to 2. The word 'or' here (denoted by ||) means that
  2169. if either condition or both hold, then the corresponding line is printed).
  2170.  
  2171. Input data (select.data):
  2172.  
  2173. x    y    z    v    u    w    i
  2174. -    -    -    -    -    -    -
  2175. 0    2    2    3    4    text1    6
  2176. 5    1    2    3    4    text2    6
  2177. 4    1    2    3    4    text3    6
  2178. 1    2    3    4    5    **    7
  2179. 2    3    4    5    6    ***    8
  2180. 3    4    5    6    7    v    9
  2181. 4    5    6    7    8    vi    10
  2182.  
  2183. The following is the output from the command
  2184. select 'z>=3&&y==2' < select.data
  2185.  
  2186. x    y    z    v    u    w    i
  2187. -    -    -    -    -    -    -
  2188. 1    2    3    4    5    **    7
  2189. (The above select-command selects those lines in the
  2190. input file where z is greater-than-or-equal-to 3 AND
  2191. y is equal to 2. The word 'AND' here (denoted by &&) means that
  2192. only if both conditions hold, then the corresponding line is printed).
  2193. \Rogue\Monster\
  2194. else
  2195.   echo "will not over write ./testdb/select.res"
  2196. fi
  2197. if `test ! -s ./testdb/jointable.data`
  2198. then
  2199. echo "writting ./testdb/jointable.data"
  2200. cat > ./testdb/jointable.data << '\Rogue\Monster\'
  2201. x    y    z    v    u    w    i
  2202. -    -    -    -    -    -    -
  2203. 0    1    2    3    4    *    6
  2204. 1    2    3    4    5    **    7
  2205. 2    3    4    5    6    ***    8
  2206. 3    4    5    6    7    v    9
  2207. 4    5    6    7    8    vi    10
  2208. \Rogue\Monster\
  2209. else
  2210.   echo "will not over write ./testdb/jointable.data"
  2211. fi
  2212. if `test ! -s ./testdb/join.dat1`
  2213. then
  2214. echo "writting ./testdb/join.dat1"
  2215. cat > ./testdb/join.dat1 << '\Rogue\Monster\'
  2216. x    y    z
  2217. -    -    -
  2218. 10    1    2
  2219. 9    2    3
  2220. 8    3    4
  2221. 7    4    5
  2222. 6    5    6
  2223. \Rogue\Monster\
  2224. else
  2225.   echo "will not over write ./testdb/join.dat1"
  2226. fi
  2227. if `test ! -s ./testdb/join.dat2`
  2228. then
  2229. echo "writting ./testdb/join.dat2"
  2230. cat > ./testdb/join.dat2 << '\Rogue\Monster\'
  2231. x    v    u    w    i
  2232. -    -    -    -    -
  2233. 5    3    4    *    6
  2234. 6    4    5    **    7
  2235. 7    5    6    ***    8
  2236. 8    6    7    v    9
  2237. 4    7    8    vi    10
  2238. \Rogue\Monster\
  2239. else
  2240.   echo "will not over write ./testdb/join.dat2"
  2241. fi
  2242. if `test ! -s ./testdb/subtotal.res`
  2243. then
  2244. echo "writting ./testdb/subtotal.res"
  2245. cat > ./testdb/subtotal.res << '\Rogue\Monster\'
  2246.  
  2247. Input data (subtotal.data):
  2248.  
  2249. ex1    w    y    z    v    u    extra
  2250. ---    -    -    -    -    -    -----
  2251. 25    0    9    2    3    4    -3
  2252. 4    0    2    2    3    4    -2
  2253. 5    0    3    4    5    6    -3
  2254. 5    2    3    4    6    7    -4
  2255. 9    2    5    6    7    10    -3
  2256. 9    2    5    6    120    8    -116
  2257. 9    23    5    6    7    8    16
  2258. 25    0    9    2    3    4    -3
  2259. 25    2    9    2    5    6    -3
  2260.  
  2261. The following is the output from the command
  2262. subtotal by w on y < subtotal.data
  2263.  
  2264. w    y
  2265. -    -
  2266. 0    14
  2267. 2    13
  2268. 23    5
  2269. 0    9
  2270. 2    9
  2271.  
  2272. Input data (subtotal.data):
  2273.  
  2274. ex1    w    y    z    v    u    extra
  2275. ---    -    -    -    -    -    -----
  2276. 25    0    9    2    3    4    -3
  2277. 4    0    2    2    3    4    -2
  2278. 5    0    3    4    5    6    -3
  2279. 5    2    3    4    6    7    -4
  2280. 9    2    5    6    7    10    -3
  2281. 9    2    5    6    120    8    -116
  2282. 9    23    5    6    7    8    16
  2283. 25    0    9    2    3    4    -3
  2284. 25    2    9    2    5    6    -3
  2285.  
  2286. The following is the output from the command
  2287. subtotal by y z on u w v < subtotal.data
  2288.  
  2289. y    z    u    w    v
  2290. -    -    -    -    -
  2291. 9    2    4    0    3
  2292. 2    2    4    0    3
  2293. 3    4    13    2    11
  2294. 5    6    26    27    134
  2295. 9    2    10    2    8
  2296. Note that the input is not automatically sorted by
  2297. subtotal - however, the project command is run first, to reorder
  2298. the columns. To see explicitly how 'subtotal by y z on u w v' works, here 
  2299. is the output of 'project y z u w v < subtotal.data' :
  2300. y    z    u    w    v
  2301. -    -    -    -    -
  2302. 9    2    4    0    3
  2303. 2    2    4    0    3
  2304. 3    4    6    0    5
  2305. 3    4    7    2    6
  2306. 5    6    10    2    7
  2307. 5    6    8    2    120
  2308. 5    6    8    23    7
  2309. 9    2    4    0    3
  2310. 9    2    6    2    5
  2311. \Rogue\Monster\
  2312. else
  2313.   echo "will not over write ./testdb/subtotal.res"
  2314. fi
  2315. if `test ! -s ./testdb/README`
  2316. then
  2317. echo "writting ./testdb/README"
  2318. cat > ./testdb/README << '\Rogue\Monster\'
  2319. Some scripts to test the various reldb commands.
  2320. Type 'make' to run the test scripts, *.prog.
  2321.  
  2322. The expected output is already given in *.res. 
  2323.  
  2324. The 'make' command yields output which is in *.tmp.
  2325. This should be the same as in the *.res-files. Diff is
  2326. run by make to compare the sets. The diff-output is placed in
  2327. *.diff. These files should be empty, with the possible
  2328. exception of rounding errors (after the 6th digit).
  2329. \Rogue\Monster\
  2330. else
  2331.   echo "will not over write ./testdb/README"
  2332. fi
  2333. if `test ! -s ./testdb/select.prog`
  2334. then
  2335. echo "writting ./testdb/select.prog"
  2336. cat > ./testdb/select.prog << '\Rogue\Monster\'
  2337. #!/bin/sh
  2338. #
  2339. # Shell script to test select reldb program.
  2340. #
  2341. BINDIR=$1
  2342. INPUTFILE=$2
  2343. PATH=$PATH:$BINDIR
  2344. export PATH
  2345. #Test select command
  2346. COMMAND=select
  2347. ARG='z>=3||y==2'
  2348. echo ; echo "Input data ($INPUTFILE):" ; echo
  2349. cat $INPUTFILE
  2350. echo;echo The following is the output from the command
  2351. echo "$COMMAND '$ARG' < $INPUTFILE"
  2352. echo
  2353. $COMMAND $ARG < $INPUTFILE
  2354. #
  2355. # Stick some explanations in:
  2356. #
  2357. echo "(The above $COMMAND-command selects those lines in the
  2358. input file where either z is greater-than-or-equal-to 3 or
  2359. y is equal to 2. The word 'or' here (denoted by ||) means that
  2360. if either condition or both hold, then the corresponding line is printed)."
  2361.  
  2362. # Second test
  2363. COMMAND=select
  2364. ARG='z>=3&&y==2'
  2365. echo ; echo "Input data ($INPUTFILE):" ; echo
  2366. cat $INPUTFILE
  2367. echo;echo The following is the output from the command
  2368. echo "$COMMAND '$ARG' < $INPUTFILE"
  2369. echo
  2370. $COMMAND $ARG < $INPUTFILE
  2371. #
  2372. # Stick some explanations in:
  2373. #
  2374. echo "(The above $COMMAND-command selects those lines in the
  2375. input file where z is greater-than-or-equal-to 3 AND
  2376. y is equal to 2. The word 'AND' here (denoted by &&) means that
  2377. only if both conditions hold, then the corresponding line is printed)."
  2378. \Rogue\Monster\
  2379. else
  2380.   echo "will not over write ./testdb/select.prog"
  2381. fi
  2382. if `test ! -s ./testdb/jointable.res`
  2383. then
  2384. echo "writting ./testdb/jointable.res"
  2385. cat > ./testdb/jointable.res << '\Rogue\Monster\'
  2386.  
  2387. Input data (join.dat1):
  2388.  
  2389. x    y    z
  2390. -    -    -
  2391. 10    1    2
  2392. 9    2    3
  2393. 8    3    4
  2394. 7    4    5
  2395. 6    5    6
  2396.  
  2397. The following is the output from the command
  2398. sorttable  < join.dat1 > tmp.joint.1
  2399.  
  2400. x    y    z
  2401. -    -    -
  2402. 10    1    2
  2403. 6    5    6
  2404. 7    4    5
  2405. 8    3    4
  2406. 9    2    3
  2407.  
  2408. Input data (join.dat2):
  2409.  
  2410. x    v    u    w    i
  2411. -    -    -    -    -
  2412. 5    3    4    *    6
  2413. 6    4    5    **    7
  2414. 7    5    6    ***    8
  2415. 8    6    7    v    9
  2416. 4    7    8    vi    10
  2417.  
  2418. The following is the output from the command
  2419. sorttable  < join.dat2 > tmp.joint.2
  2420.  
  2421. x    v    u    w    i
  2422. -    -    -    -    -
  2423. 4    7    8    vi    10
  2424. 5    3    4    *    6
  2425. 6    4    5    **    7
  2426. 7    5    6    ***    8
  2427. 8    6    7    v    9
  2428.  
  2429. The following is the output from the command
  2430. jointable tmp.joint.1 tmp.joint.2
  2431.  
  2432. x    y    z    v    u    w    i
  2433. -    -    -    -    -    -    -
  2434. 6    5    6    4    5    **    7
  2435. 7    4    5    5    6    ***    8
  2436. 8    3    4    6    7    v    9
  2437. \Rogue\Monster\
  2438. else
  2439.   echo "will not over write ./testdb/jointable.res"
  2440. fi
  2441. if `test ! -s ./testdb/union.prog`
  2442. then
  2443. echo "writting ./testdb/union.prog"
  2444. cat > ./testdb/union.prog << '\Rogue\Monster\'
  2445. #!/bin/sh
  2446. #
  2447. # Shell script to test union reldb program.
  2448. #
  2449. # Note that union requires two input files - this
  2450. # cannot be handled by the Makefile, so we simply ignore
  2451. # the files the Makefile gives us.
  2452. #
  2453. BINDIR=$1
  2454. INPUTFILE=$2
  2455. PATH=$PATH:$BINDIR
  2456. export PATH
  2457.  
  2458. #Test union command 
  2459.  
  2460. COMMAND=union
  2461. FILE1=union.dat1
  2462. FILE2=union.dat2
  2463.  
  2464. echo "The union takes two input files, e.g.
  2465. $FILE1:"
  2466. cat $FILE1
  2467.  
  2468. echo "and $FILE2:"
  2469. cat $FILE2
  2470.  
  2471. echo;echo The following is the output from the command
  2472. echo "$COMMAND $FILE1 $FILE2"
  2473. echo
  2474. $COMMAND $FILE1 $FILE2
  2475.  
  2476. \Rogue\Monster\
  2477. else
  2478.   echo "will not over write ./testdb/union.prog"
  2479. fi
  2480. if `test ! -s ./testdb/union.dat1`
  2481. then
  2482. echo "writting ./testdb/union.dat1"
  2483. cat > ./testdb/union.dat1 << '\Rogue\Monster\'
  2484. col1    col2    col3
  2485. ----    ----    ----
  2486. this    is    line1
  2487. line2    in    file1
  2488. line3    x    x
  2489. \Rogue\Monster\
  2490. else
  2491.   echo "will not over write ./testdb/union.dat1"
  2492. fi
  2493. if `test ! -s ./testdb/union.dat2`
  2494. then
  2495. echo "writting ./testdb/union.dat2"
  2496. cat > ./testdb/union.dat2 << '\Rogue\Monster\'
  2497. col1    col2    col3
  2498. ----    ----    ----
  2499. this is    line1    in file2
  2500. line2    in    file2
  2501. \Rogue\Monster\
  2502. else
  2503.   echo "will not over write ./testdb/union.dat2"
  2504. fi
  2505. if `test ! -s ./testdb/union.data`
  2506. then
  2507. echo "writting ./testdb/union.data"
  2508. cat > ./testdb/union.data << '\Rogue\Monster\'
  2509. \Rogue\Monster\
  2510. else
  2511.   echo "will not over write ./testdb/union.data"
  2512. fi
  2513. if `test ! -s ./testdb/addcol.res`
  2514. then
  2515. echo "writting ./testdb/addcol.res"
  2516. cat > ./testdb/addcol.res << '\Rogue\Monster\'
  2517.  
  2518. Input data (file addcol.data)
  2519.  
  2520. x    y    z    v    u
  2521. -    -    -    -    -
  2522. 0    9    2    3    4
  2523. 1    2    2    3    4
  2524. 2    3    4    5    6
  2525. 2    3    5    6    7
  2526. 4    5    6    7    8
  2527.  
  2528. The following is the output from the command
  2529. addcol www zzz < addcol.data
  2530.  
  2531. x    y    z    v    u    www    zzz
  2532. -    -    -    -    -    ---    ---
  2533. 0    9    2    3    4
  2534. 1    2    2    3    4
  2535. 2    3    4    5    6
  2536. 2    3    5    6    7
  2537. 4    5    6    7    8
  2538. \Rogue\Monster\
  2539. else
  2540.   echo "will not over write ./testdb/addcol.res"
  2541. fi
  2542. if `test ! -s ./testdb/recode.prog`
  2543. then
  2544. echo "writting ./testdb/recode.prog"
  2545. cat > ./testdb/recode.prog << '\Rogue\Monster\'
  2546. #!/bin/sh
  2547. #
  2548. # Shell script to test recode reldb program.
  2549. #
  2550. #
  2551. BINDIR=$1
  2552. INPUTFILE=$2
  2553. PATH=$BINDIR:$PATH
  2554. export PATH
  2555.  
  2556. CODEFILE=recode.codes
  2557.  
  2558. COMMAND=recode
  2559. ARG="$CODEFILE"
  2560.  
  2561. echo ; echo "Input data ($INPUTFILE):" ; echo
  2562. cat $INPUTFILE
  2563.  
  2564. echo ;echo "Code file ($CODEFILE):" ; echo
  2565. cat $CODEFILE
  2566.  
  2567. echo;echo The following is the output from the command
  2568. echo "$COMMAND $ARG < $INPUTFILE"
  2569. echo
  2570. $COMMAND $ARG < $INPUTFILE
  2571.  
  2572. \Rogue\Monster\
  2573. else
  2574.   echo "will not over write ./testdb/recode.prog"
  2575. fi
  2576. if `test ! -s ./testdb/recode.data`
  2577. then
  2578. echo "writting ./testdb/recode.data"
  2579. cat > ./testdb/recode.data << '\Rogue\Monster\'
  2580. ex1    w    y    z    v    u    extra
  2581. ---    -    -    -    -    -    -----
  2582. 25    0    9    2    3    4    -3
  2583. 4    0    2    2    3    4    -2
  2584. 5    0    3    4    5    6    -3
  2585. 5    2    3    4    6    7    -4
  2586. 9    2    5    6    7    10    -3
  2587. 9    2    5    6    120    8    -116
  2588. 9    23    5    6    7    8    16
  2589. 25    0    9    2    3    4    -3
  2590. 25    2    9    2    5    6    -3
  2591. \Rogue\Monster\
  2592. else
  2593.   echo "will not over write ./testdb/recode.data"
  2594. fi
  2595. if `test ! -s ./testdb/recode.codes`
  2596. then
  2597. echo "writting ./testdb/recode.codes"
  2598. cat > ./testdb/recode.codes << '\Rogue\Monster\'
  2599. ex1    new
  2600. ---    ---
  2601. 1    20
  2602. 2    21
  2603. 3    22
  2604. 4    23
  2605. 5    24
  2606. 9    25
  2607. 25    0
  2608. \Rogue\Monster\
  2609. else
  2610.   echo "will not over write ./testdb/recode.codes"
  2611. fi
  2612. if `test ! -s ./testdb/math.data`
  2613. then
  2614. echo "writting ./testdb/math.data"
  2615. cat > ./testdb/math.data << '\Rogue\Monster\'
  2616. x    y    z    v
  2617. -    -    -    -
  2618. 0    1    2    3
  2619. 1        3    4
  2620. 2    3    4    5
  2621. 3    4    5    6
  2622. 4    5    6    7
  2623. \Rogue\Monster\
  2624. else
  2625.   echo "will not over write ./testdb/math.data"
  2626. fi
  2627. if `test ! -s ./testdb/math.res`
  2628. then
  2629. echo "writting ./testdb/math.res"
  2630. cat > ./testdb/math.res << '\Rogue\Monster\'
  2631.  
  2632. Input data (math.data):
  2633.  
  2634. x    y    z    v
  2635. -    -    -    -
  2636. 0    1    2    3
  2637. 1        3    4
  2638. 2    3    4    5
  2639. 3    4    5    6
  2640. 4    5    6    7
  2641.  
  2642. The following is the output from the command
  2643. math  < math.data
  2644.  
  2645. x    y    z    v    Type
  2646. -    -    -    -    ----
  2647. 5    4    5    5    Freq
  2648. 10    13    20    25    Sum
  2649. 2    3    4    5    Mean
  2650. 1.58114    1.70783    1.58114    1.58114    Stddev
  2651. 4    5    6    7    Maximum
  2652. 0    1    2    3    Minimum
  2653. \Rogue\Monster\
  2654. else
  2655.   echo "will not over write ./testdb/math.res"
  2656. fi
  2657. if `test ! -s ./testdb/math.prog`
  2658. then
  2659. echo "writting ./testdb/math.prog"
  2660. cat > ./testdb/math.prog << '\Rogue\Monster\'
  2661. #!/bin/sh
  2662. #
  2663. # Shell script to test math reldb program.
  2664. #
  2665. #
  2666. BINDIR=$1
  2667. INPUTFILE=$2
  2668. PATH=$BINDIR:$PATH
  2669. export PATH
  2670.  
  2671.  
  2672. COMMAND=math
  2673. ARG=""
  2674.  
  2675. echo ; echo "Input data ($INPUTFILE):" ; echo
  2676. cat $INPUTFILE
  2677.  
  2678. echo;echo The following is the output from the command
  2679. echo "$COMMAND $ARG < $INPUTFILE"
  2680. echo
  2681. $COMMAND $ARG < $INPUTFILE
  2682.  
  2683. \Rogue\Monster\
  2684. else
  2685.   echo "will not over write ./testdb/math.prog"
  2686. fi
  2687. if `test ! -s ./testdb/recode.res`
  2688. then
  2689. echo "writting ./testdb/recode.res"
  2690. cat > ./testdb/recode.res << '\Rogue\Monster\'
  2691.  
  2692. Input data (recode.data):
  2693.  
  2694. ex1    w    y    z    v    u    extra
  2695. ---    -    -    -    -    -    -----
  2696. 25    0    9    2    3    4    -3
  2697. 4    0    2    2    3    4    -2
  2698. 5    0    3    4    5    6    -3
  2699. 5    2    3    4    6    7    -4
  2700. 9    2    5    6    7    10    -3
  2701. 9    2    5    6    120    8    -116
  2702. 9    23    5    6    7    8    16
  2703. 25    0    9    2    3    4    -3
  2704. 25    2    9    2    5    6    -3
  2705.  
  2706. Code file (recode.codes):
  2707.  
  2708. ex1    new
  2709. ---    ---
  2710. 1    20
  2711. 2    21
  2712. 3    22
  2713. 4    23
  2714. 5    24
  2715. 9    25
  2716. 25    0
  2717.  
  2718. The following is the output from the command
  2719. recode recode.codes < recode.data
  2720.  
  2721. new    ex1    w    y    z    v    u    extra
  2722. ---    ---    -    -    -    -    -    -----
  2723. 0    25    0    9    2    3    4    -3
  2724. 23    4    0    2    2    3    4    -2
  2725. 24    5    0    3    4    5    6    -3
  2726. 24    5    2    3    4    6    7    -4
  2727. 25    9    2    5    6    7    10    -3
  2728. 25    9    2    5    6    120    8    -116
  2729. 25    9    23    5    6    7    8    16
  2730. 0    25    0    9    2    3    4    -3
  2731. 0    25    2    9    2    5    6    -3
  2732. \Rogue\Monster\
  2733. else
  2734.   echo "will not over write ./testdb/recode.res"
  2735. fi
  2736. if `test ! -d ./testgr`
  2737. then
  2738.   mkdir ./testgr
  2739.   echo "mkdir ./testgr"
  2740. fi
  2741. if `test ! -s ./testgr/README`
  2742. then
  2743. echo "writting ./testgr/README"
  2744. cat > ./testgr/README << '\Rogue\Monster\'
  2745. Some sample uses of scat.
  2746.  
  2747. README
  2748. data.*        Some data files
  2749. t?        A few sample scat-commands. Run them with
  2750.         e.g. t1 | xplot =500x500+100+100
  2751.         or   t2 | plot -Ttek
  2752.         etc
  2753.  
  2754. Note that t4 uses extended plot(5)-commands.
  2755. \Rogue\Monster\
  2756. else
  2757.   echo "will not over write ./testgr/README"
  2758. fi
  2759. if `test ! -s ./testgr/t1`
  2760. then
  2761. echo "writting ./testgr/t1"
  2762. cat > ./testgr/t1 << '\Rogue\Monster\'
  2763. #!/bin/sh
  2764. #
  2765. # Very basic -- no options
  2766.  
  2767. scat < data.smpl
  2768. \Rogue\Monster\
  2769. else
  2770.   echo "will not over write ./testgr/t1"
  2771. fi
  2772. if `test ! -s ./testgr/data.smpl`
  2773. then
  2774. echo "writting ./testgr/data.smpl"
  2775. cat > ./testgr/data.smpl << '\Rogue\Monster\'
  2776. x    y
  2777. -    -
  2778. 0    1
  2779. 1    2
  2780. 2    3
  2781. 3    4
  2782. 4    5
  2783. \Rogue\Monster\
  2784. else
  2785.   echo "will not over write ./testgr/data.smpl"
  2786. fi
  2787. if `test ! -s ./testgr/t2`
  2788. then
  2789. echo "writting ./testgr/t2"
  2790. cat > ./testgr/t2 << '\Rogue\Monster\'
  2791. #!/bin/sh
  2792. #
  2793. # Basic x,y-plot, but scaling axes
  2794.  
  2795. scat -x0,5,.5 -y 0,5,0.5 -H "Sample x/y-plot" < data.smpl
  2796. \Rogue\Monster\
  2797. else
  2798.   echo "will not over write ./testgr/t2"
  2799. fi
  2800. if `test ! -s ./testgr/t3`
  2801. then
  2802. echo "writting ./testgr/t3"
  2803. cat > ./testgr/t3 << '\Rogue\Monster\'
  2804. #!/bin/sh
  2805. # Slightly more complex plot. Data contains 3 columns.
  2806. # Plot contains col2(z) vs col1(y) as a line, with col4(w) as labels
  2807. # at the points (col1,col3) or (v,y)
  2808. # This is what the data looks like:
  2809. #
  2810. # y    z    v    w
  2811. # -    -    -    -
  2812. # 1    2    3    *
  2813. # 2    3    4    **
  2814. # 3    4    5    ***
  2815. # 4    5    6    v
  2816. # 5    6    7    vi
  2817. scat \
  2818.     -X "X-axis" \
  2819.     -Y "Y-axis" \
  2820.     -x0,5,.5 \
  2821.     -y 0,10,1 \
  2822.     -L w \
  2823.     -H "Sample x/y-plot" \
  2824.     < data.3
  2825. #
  2826. # Note the use of -X and -Y to define axis labels.
  2827. # The Y-axis label is not rotated unless the -E option is added to
  2828. # the scat command-line. In this case, extended commands must be
  2829. # supported by the plot-filter used.
  2830. \Rogue\Monster\
  2831. else
  2832.   echo "will not over write ./testgr/t3"
  2833. fi
  2834. if `test ! -s ./testgr/data.3`
  2835. then
  2836. echo "writting ./testgr/data.3"
  2837. cat > ./testgr/data.3 << '\Rogue\Monster\'
  2838. y    z    v    w
  2839. -    -    -    -
  2840. 1    2    3    *
  2841. 2    3    4    **
  2842. 3    4    5    ***
  2843. 4    5    6    v
  2844. 5    6    7    vi
  2845. \Rogue\Monster\
  2846. else
  2847.   echo "will not over write ./testgr/data.3"
  2848. fi
  2849. if `test ! -s ./testgr/data.cmplx`
  2850. then
  2851. echo "writting ./testgr/data.cmplx"
  2852. cat > ./testgr/data.cmplx << '\Rogue\Monster\'
  2853. x    y    z    v    u    w    i
  2854. -    -    -    -    -    -    -
  2855. 0    1    2    3    4    *    6
  2856. 1    2    3    4    5    **    7
  2857. 2    3    4    5    6    ***    8
  2858. 3    4    5    6    7    v    9
  2859. 4    5    6    7    8    vi    10
  2860. \Rogue\Monster\
  2861. else
  2862.   echo "will not over write ./testgr/data.cmplx"
  2863. fi
  2864. if `test ! -s ./testgr/t4`
  2865. then
  2866. echo "writting ./testgr/t4"
  2867. cat > ./testgr/t4 << '\Rogue\Monster\'
  2868. #!/bin/sh
  2869. # Input data (data.cmplx):
  2870. #
  2871. # x    y    z    v    u    w    i
  2872. # -    -    -    -    -    -    -
  2873. # 0    1    2    3    4    *    6
  2874. # 1    2    3    4    5    **    7
  2875. # 2    3    4    5    6    ***    8
  2876. # 3    4    5    6    7    v    9
  2877. # 4    5    6    7    8    vi    10
  2878. #
  2879. # Draw two plots in the same window (or on same paper, etc).
  2880. #
  2881. # First plot is y vs x, with lines through the points and
  2882. # also labels w at the points. For this, the y-column must
  2883. # come twice (once for the line and once for the w's). The project and
  2884. # compute statements accomplish this.
  2885. project x y newy w < data.cmplx |
  2886.     compute 'newy=y' |
  2887.     scat \
  2888.         -H "First figure" \
  2889.         -X "Sample X axis" \
  2890.         -Y "Rotated Y" \
  2891.         -E \
  2892.         -Lw \
  2893.         -x 0,5,0.5 \
  2894.         -y 0,5,0.5 \
  2895.         -w 0,0,0.5,0.5
  2896.  
  2897. # Second plot has points (x,y), (u,x), and labels i at (v,x):
  2898. project x y u v w <data.cmplx |
  2899.     scat \
  2900.         -H "Second figure" \
  2901.         -X "Sample X axis" \
  2902.         -e  \
  2903.         -Y "NONrotated" \
  2904.         -Lw \
  2905.         -x 0,10,1 \
  2906.         -y 0,10,1 \
  2907.         -w 0,0.5,1,1
  2908.  
  2909. # NOTE: The -E option is used in the first example.
  2910. # This uses the extplotlib routines, which demand rotation and centering
  2911. # of text. Centering has been implemented in the enclosed xplot and hpglplot
  2912. # filters (essential for labels to make any sense). Rotation (of Y axis)
  2913. # has currently only been implemented in hpglplot, and makes much nicer plots.
  2914. \Rogue\Monster\
  2915. else
  2916.   echo "will not over write ./testgr/t4"
  2917. fi
  2918. if `test ! -s ./testgr/data.legend`
  2919. then
  2920. echo "writting ./testgr/data.legend"
  2921. cat > ./testgr/data.legend << '\Rogue\Monster\'
  2922. x    y    z    zlabel    ylegend    zlegend
  2923. -    -    -    ------    -------    -------
  2924. 1    2    4    x        
  2925. 2    3    3            
  2926. 3    1    3    xx        
  2927. 4    1    4        y-label    z-label
  2928. \Rogue\Monster\
  2929. else
  2930.   echo "will not over write ./testgr/data.legend"
  2931. fi
  2932. if `test ! -s ./testgr/t5`
  2933. then
  2934. echo "writting ./testgr/t5"
  2935. cat > ./testgr/t5 << '\Rogue\Monster\'
  2936.    project x y z z zlabel y ylegend z zlegend < data.legend | 
  2937.     scat -E -x 0,10,1 -y 0,10,1 -L zlabel -L ylegend -L zlegend | 
  2938.     plot -Tx =500x500+1+1
  2939. \Rogue\Monster\
  2940. else
  2941.   echo "will not over write ./testgr/t5"
  2942. fi
  2943. if `test ! -s ./testgr/t6`
  2944. then
  2945. echo "writting ./testgr/t6"
  2946. cat > ./testgr/t6 << '\Rogue\Monster\'
  2947.    project x y z z zlabel y ylegend z zlegend < data.legend | 
  2948.     scat -E -x 0,10,1 -y 0,10,1 -L zlabel -L ylegend -L zlegend | 
  2949.     plot -Tx =500x500+1+1
  2950. \Rogue\Monster\
  2951. else
  2952.   echo "will not over write ./testgr/t6"
  2953. fi
  2954. if `test ! -s ./testgr/t3e`
  2955. then
  2956. echo "writting ./testgr/t3e"
  2957. cat > ./testgr/t3e << '\Rogue\Monster\'
  2958. #!/bin/sh
  2959. # Slightly more complex plot. Data contains 3 columns.
  2960. # Plot contains col2(z) vs col1(y) as a line, with col4(w) as labels
  2961. # at the points (col1,col3) or (v,y)
  2962. # This is what the data looks like:
  2963. #
  2964. # y    z    v    w
  2965. # -    -    -    -
  2966. # 1    2    3    *
  2967. # 2    3    4    **
  2968. # 3    4    5    ***
  2969. # 4    5    6    v
  2970. # 5    6    7    vi
  2971. scat \
  2972.     -X "X-axis" \
  2973.     -Y "Y-axis" \
  2974.     -E \
  2975.     -x0,5,.5 \
  2976.     -y 0,10,1 \
  2977.     -L w \
  2978.     -H "Sample x/y-plot" \
  2979.     < data.3
  2980. #
  2981. # Note the use of -X and -Y to define axis labels.
  2982. # The Y-axis label is not rotated unless the -E option is added to
  2983. # the scat command-line. In this case, extended commands must be
  2984. # supported by the plot-filter used.
  2985. \Rogue\Monster\
  2986. else
  2987.   echo "will not over write ./testgr/t3e"
  2988. fi
  2989. echo "Finished archive 1 of 3"
  2990. exit
  2991.  
  2992.