home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOPAS
/
MAPSTATF.LBR
/
PLOT.PZS
/
PLOT.ÐAS
Wrap
Text File
|
2000-06-30
|
7KB
|
211 lines
(* Multivariate Analysis Package - Bivariate Plotting Module
Copyright 1985 Douglas L. Anderton. This program may be freely
circulated so long as it is not sold for profit and any charge does
not exceed costs of reproduction. *)
{ set printer control codes in procedure openfiles }
Program Plot(Input,Output);
Const
N=20;
Type
SUBS = 1..N;
RVEC = Array [SUBS] Of Real;
SVEC = Array [1..21] Of String[1];
IVEC = Array [SUBS] Of Integer;
S8 = Array [SUBS] Of String[8];
PLT = Array [1..60] Of String[120];
Var
dfile, ofile : Text;
sel : IVEC;
miss, vars : RVEC;
title : String[80];
varn : S8;
nc, i, j, k, l, nv, ix, dv, ot : Integer;
xmin, xmax, xscl, ymin, ymax, yscl : Real;
sym : SVEC;
g : PLT;
Function Rmin(value1, value2: Real): Real;
Begin If value1<value2 Then Rmin:=value1 Else Rmin:=value2 End;
Function Rmax(value1, value2: Real): Real;
Begin If value1>value2 Then Rmax:=value1 Else Rmax:=value2 End;
Procedure openfiles(Var dfile, ofile:Text; Var ot:Integer);
Var
dfl, ofl:String[12];
Begin
ClrScr; Writeln(' *** PLOT: 2-DIMENSIONAL DATA PLOTTING ***');
Writeln; Writeln('Output is to LST: - Turn Your Printer On.');
ofl:='LST:'; Assign(ofile,ofl); Rewrite(ofile); ot:=2;
Write('Name of the data file? ');
Readln(dfl); Assign(dfile,dfl); Reset(dfile);
(* EPSON MX/FX set to 1/8 line spacing and compressed print *)
Writeln(ofile,#$12);
Writeln(ofile,'Multivariate Analysis Package (1.6) - ',
'Program: PLOT, Datafile: ',dfl);
Writeln(ofile,#$1B#$30#$0F); Writeln(ofile);
End; (* Of openfiles *)
Procedure symbols(varn:S8; dv, j:Integer; Var sym:SVEC);
Var
i:Integer;
Begin
Writeln;
For i:=1 To dv-j Do
Begin
Write('Plotting Symbol to use for ',varn[i],'? ');Readln(sym[i]);
End;
Write('Plotting Symbol to use for collision? ');Readln(sym[21]);
End; (* Of symbols *)
Procedure selcvar(Var sel:IVEC; Var varn:S8; Var miss:RVEC;
Var ij, nv, dv:Integer);
Var
cfile:Text;
cfl:String[12];
i,j,f:Integer;
mis:Real;
van:String[8];
Begin
Write('Name of the codebook file (or NONE)? '); Readln(cfl);
If (cfl<>'NONE') And (cfl<>'none') Then f:=1 Else f:=0;
If f=1 Then Begin Assign(cfile,cfl); Reset(cfile); End;
Writeln;
Write('How many variables in data file? '); Readln(nv);
Write('Number of variables to use in PLOT? '); Readln(dv);
ij:=0;
Write('Column number for X variable (0=case number)? ');Readln(sel[dv]);
If sel[dv]>0 Then
Begin
Str(sel[dv]:3,varn[dv]); miss[dv]:=-1E37;
ij:=1;
End;
Writeln;
For i:=1 To dv-ij Do
Begin
Write('Column number for Y variable ',i,'? '); Readln(sel[i]);
Str(sel[i]:3,varn[i]); miss[i]:=-1E37;
End;
If f=1 Then Begin
For j:=1 to nv Do Begin
mis:=-1E37;
Readln(cfile,f,van,mis);
For i:=1 to dv Do
If f=sel[i] Then Begin
varn[i]:=van; miss[i]:=mis;
Writeln('Col: ',sel[i],' Name: ',varn[i],' Missing: ',miss[i]:6);
End;
End;
Close(cfile);
End;
End; (* Of selcvar *)
Procedure getcase(Var vars:RVEC; sel:IVEC; nv, dv:Integer; Var dfile:Text);
Var
i, j:Integer;
x:Real;
Begin
For i:=1 To nv Do
Begin
Read(dfile,x);
For j:=1 To dv Do If (sel[j]=i) Then vars[j]:=x;
End;
End; (* Of getcase *)
Begin (* main *)
openfiles(dfile, ofile, ot);
selcvar(sel, varn, miss, ix, nv, dv);
symbols(varn, dv, ix, sym);
(* initialize *)
FillChar(g,60*120,' ');
nc:=0; xmin:=1E30; xmax:=-1E30; ymin:=1E30; ymax:=-1E30;
If ix=0 Then xmin:=1;
(* Read for max and min *)
Writeln; Writeln('1st Pass:');
While Not EOF(dfile) Do Begin
getcase(vars, sel, nv, dv, dfile);
j:=0;
If Not EOF(dfile) Then Begin
For i:=1 to dv Do If vars[i]=miss[i] Then j:=1;
If j=0 Then Begin
nc:=nc+1;
If Frac(nc/10)=0.0 Then Write('+');
If ix=0 Then xmax:=nc
Else Begin
xmin:=Rmin(vars[dv],xmin); xmax:=Rmax(vars[dv],xmax); End;
For i:=1 To dv-ix Do Begin
ymin:=Rmin(vars[i],ymin); ymax:=Rmax(vars[i],ymax); End;
End;
End;
End;
(* scale graph *)
ClrScr; Writeln;
Write('Minimum for X Axis (',xmin:8,'=default)? ');Readln(xmin);
Write('Maximum for X Axis (',xmax:8,'=default)? ');Readln(xmax);
Write('Minimum for Y Axis (',ymin:8,'=default)? ');Readln(ymin);
Write('Maximum for Y Axis (',ymax:8,'=default)? ');Readln(ymax);
xscl:=119.0/(xmax-xmin); yscl:=59.0/(ymax-ymin);
(* fill it *)
Reset(dfile); Writeln('2nd Pass:'); nc:=0;
While Not EOF(dfile) Do Begin
getcase(vars, sel, nv, dv, dfile);
j:=0;
If Not EOF(dfile) Then Begin
For i:=1 to dv Do If vars[i]=miss[i] Then j:=1;
If j=0 Then Begin
nc:=nc+1;
If Frac(nc/10)=0.0 Then Write('+');
If ix=0 Then k:=Trunc((nc-xmin)*xscl)+1
Else k:=Trunc((vars[dv]-xmin)*xscl)+1;
For i:=1 To dv-ix Do Begin
l:=Trunc((vars[i]-ymin)*yscl)+1;
If ((l>0) And (l<60)) And ((k>0) And (k<120)) Then
If (Copy(g[l],k,1)=' ') Then
Begin Delete(g[l],k,1); Insert(sym[i],g[l],k); End
Else Begin Delete(g[l],k,1); Insert(sym[21],g[l],k); End;
End;
End;
End;
End;
(* Output Plot *)
ClrScr;
Writeln('Title (up to 80 chars)? '); Readln(title);
Writeln(ofile,title);
Writeln(ofile);
Write(ofile,' |-');
For i:=1 To 12 Do Write(ofile,'---------|');
Writeln(ofile);
For i:=1 To 60 Do Begin
j:=61-i;
If (Frac(j/10)=0.0) Then Begin
yscl:=((ymax-ymin)/60)*j+ymin;
Writeln(ofile,yscl:8,'-|',g[j]:120,'|');
End
Else Writeln(ofile,' -|',g[j]:120,'|');
End;
Write(ofile,ymin:8,'-+|');
For i:=1 To 12 Do Write(ofile,'---------|');
Writeln(ofile); Write(ofile,' ');
For i:=0 To 12 Do Begin
xscl:=((xmax-xmin)/120)*(i*10)+xmin;
Write(ofile,xscl:8);
If i<12 Then Write(ofile,' ');
End;
Writeln(ofile); Writeln(ofile,'Legend:');
For i:=1 To dv-ix Do Begin
Write(ofile,' ',varn[i]:8,'=',sym[i]:1,' ');
If (i=13) And (dv>13) Then Writeln(ofile);
End;
If ix=0 Then varn[dv]:='Case Num ';
Writeln(ofile,' by ',varn[dv]:8);
Writeln(ofile,#$12); Writeln(ofile);
Close(dfile); Close(ofile);
Assign(dfile,'MAPSTAT.COM'); Execute(dfile);
End.
Writeln(ofile,title);
Writeln(ofile);
Write(ofile,' |-');
For i:=1 To 12 Do Write(ofile,'------