10 ' A three-dimensional Bar-graph written by Jonathan Winton, June 1983. (C)
20 'Modified 1983-07-07 -Bob Bowerman
30 'Added Automatic scaling, a routine to print the bargraph on the
40 'Printer, put any terminal/printer dependant strings up
50 'fron so that they are easily modified and allowed the user
60 'to chose the name of the output file name.
70 WIDTH 255
80 '
90 'Modify this section for customiztion ...
100 '
110 CS$=CHR$(24) 'Clear Screen
120 CE$=CHR$(23) 'Clear to End of Screen
130 IVON$=CHR$(14) 'Inverse/Highlight/Graphics on
140 IVOFF$=CHR$(15) 'Inverse/Highlight/Graphics off
150 DEF FNC$(Y,X)=CHR$(16)+CHR$(Y+32)+CHR$(X+32) 'Cursor Address
160 PRINIT$=CHR$(18) 'Initialize printer - 
170 PRESET$=CHR$(24) 'Reset Printer 
180 BARCH$="X" 'Character to use in bar
190 HORLN$="_" 'Horizontal Line char
200 VRTLN$="|" 'Vertical Line char
210 DGLN$="/"  'Diagonal Line char
220 PBARCH$="X" 'Character to use in bar for the printer
230 PHORLN$="_" 'Horizontal Line char for printer
240 PVRTLN$="|" 'Vertical Line char for printer
250 PDGLN$="/"  'Diagonal Line char for printer
260 '***** NOTE *****
270 'if HORLN$, VRTLN$, and DGLN$ are special graphics chars that must be
280 'have graphics mode switched in (ie on and OSBORNE) put the switch
290 'in & out sequence in the definitions of VRTLN$ and DGLN$, and for
300 'HORLN$ put the switch in and out chars before & after the STRING$
310 'in line 750 below:
320 '
330 'End of Customization Section
340 '
350 DEF FNR(NUM,FAC)=INT(NUM/FAC+1)*FAC
360 DIM A$(35),B(35),PB(35)
370 PRINT CS$
380 PRINT "<R>ead in graph from disk, or <T>ype in graph. ";:SS$=INPUT$(1)
390 IF SS$<>"R" THEN 460
400 INPUT "File to read in";F$
410 IF INSTR(F$,".")=0 THEN F$=F$+".GRF"
420 OPEN "I",#1,F$
430 INPUT#1,TITLE$,FACTORS,A1,MAX
440 FOR I=1 TO FACTORS:INPUT#1,A$(I):NEXT I:FOR I=1 TO FACTORS:INPUT#1,B(I)
450 NEXT:CLOSE#1:GOTO 740
460 PRINT
470 INPUT "What is the title of this graph ";TITLE$
480 IF TITLE$="" THEN 460
490 TITLE$="** "+TITLE$+" **"
500 INPUT "How many bars (35 is max.) ";FACTORS
510 IF FACTORS>35 OR FACTORS<1 THEN 500
520 PRINT
530 FOR I=1 TO FACTORS
540 PRINT "Title for bar #";I;" ";
550 INPUT A$(I)
560 NEXT I
570 FOR I=1 TO FACTORS
580 PRINT "Value of "A$(I);
590 INPUT B(I)
600 IF B(I)<1  THEN 580
610 NEXT I
620 TOP=0
630 FOR I=1 TO FACTORS
640 IF B(I)>TOP THEN TOP=B(I)
650 NEXT I
660 IF INT(TOP)<>TOP THEN TOP=INT(TOP+1)
670 MAX=TOP
680 IF MAX<100 THEN MAG=CINT(10^(LEN(STR$(MAX))-2)) ELSE MAG=CINT(10^(LEN(STR$(MAX))-3))
690 IF INT(MAX/MAG)*MAG<>MAX THEN MAX=FNR(MAX,MAG)
700 IF MAX-TOP < .1*TOP THEN MAX=MAX+1:GOTO 690
710 PRINT "How thick do you want the bars ";
720 PRINT INT((74-FACTORS)/FACTORS);" is max. ";
730 INPUT A1:IF A1*FACTORS+FACTORS<75 THEN 740 ELSE 710
740 PRINT CS$
750 Q$=STRING$(A1,BARCH$):HL$=STRING$(A1,HORLN$)
760 FOR I=0 TO 20:PRINT "   -":NEXT I
770 PRINT FNC$(1,0);MAX;FNC$(6,0);3*MAX/4;FNC$(11,0);MAX/2
780 PRINT FNC$(16,0);MAX/4;FNC$(21,0);" 0 "
790 PRINT FNC$(22,40-LEN(TITLE$)/2)TITLE$
800 TT=5
810 FOR I=1 TO FACTORS
820 IF LEN(A$(I))>A1 THEN OP$=LEFT$(A$(I),A1) ELSE OP$=A$(I)
830 PRINT FNC$(21,TT);OP$
840  TT=TT+LEN(Q$)+1
850 NEXT I
860 X=21:H=5
870 FOR I=1 TO FACTORS
880 FOR II=1 TO B(I) STEP MAX/20
890 X=X-1:PRINT FNC$(X,H);IVON$;Q$;IVOFF$:NEXT II
900 PRINT FNC$(X-1,H);DGLN$;SPC(A1-1);DGLN$;:PRINT FNC$(X-2,H+1)+HL$
910 H=H+A1+1:X=21
920 BB=B(I)
930 X=20
940 FOR II=1 TO BB STEP MAX/20
950 X=X-1:PRINT FNC$(X,H);VRTLN$:NEXT II
960 PRINT FNC$(20,H-1)DGLN$
970 X=21
980 NEXT I
990 PRINT FNC$(23,0)CE$;"<S>ave, <D>o again, <N>ew graph, <C>hange , or <P>rint.";
1000 I$=INPUT$(1)
1010 IF I$="P" THEN 1200
1020 IF I$<>"S" AND I$<>"N" AND I$<>"D" AND I$<>"C" THEN 1000
1030 IF I$="N" THEN GOTO 370
1040 IF I$="C" THEN 1090
1050 IF I$="S" THEN 1130
1060 IF I$="D" THEN PRINT CS$:PRINT "New size, ";INT(((76-FACTORS)/FACTORS)-.4);" is max. ";
1070 INPUT A1:IF A1*FACTORS+FACTORS<75 AND A1>0 THEN 1080 ELSE 1060
1080 GOTO 740
1090 PRINT FNC$(22,0);CE$;"Enter the bar number to change ";:INPUT LE
1100 PRINT CS$
1110 PRINT "The value for ";A$(LE);" is ";B(LE);", what do you want to change it to";:INPUT B(LE)
1120 GOTO 620
1130 PRINT FNC$(23,0);CE$;:INPUT; "File name to save graph under";F$
1140 IF INSTR(F$,".")=0 THEN F$=F$+".GRF"
1150 OPEN "O",#1,F$
1160 PRINT#1,TITLE$;",";STR$(FACTORS);",";STR$(A1);",";STR$(MAX);",";
1170 FOR I=1 TO FACTORS:PRINT#1,A$(I);",";:NEXT I
1180 FOR I=1 TO FACTORS:PRINT#1,STR$(B(I));",";:NEXT I
1190 CLOSE#1:GOTO 990
1200 'Print out routine
1210 PRINT FNC$(23,0);CE$;
1220 INPUT;"How long should the graph be? (20,40,80) ";GLEN
1230 IF GLEN<>20 AND GLEN<>40 AND GLEN<>80 THEN 1210
1240 LN1=MAX/GLEN:LN2=2*LN1:STP=-LN1:MIN=LN1-.1
1250 TQ=(3*GLEN)/4+1:HLF=GLEN/2+1:OQ=GLEN/4+1
1260 LPRINT PRINIT$
1270 I=1
1280 FOR II=MAX TO 1 STEP STP
1290 IF I=1 THEN LPRINT MAX;:GOTO 1340
1300 IF I=OQ THEN LPRINT (3*MAX)/4;:GOTO 1340
1310 IF I=HLF THEN LPRINT MAX/2;: GOTO 1340
1320 IF I=TQ THEN LPRINT MAX/4;:GOTO 1340
1330 LPRINT "    -";
1340 TT=7
1350 FOR I1=1 TO FACTORS
1360 IF B(I1) < MIN THEN PB(I1)=INT(MIN) ELSE PB(I1)=B(I1)
1370 NEXT
1380 FOR I1=1 TO FACTORS
1390 IF II <= PB(I1) THEN LPRINT TAB(TT);STRING$(A1,PBARCH$);:GOTO 1420
1400 IF II<= PB(I1)+LN1 THEN LPRINT TAB(TT);PDGLN$;SPC(A1-1);PDGLN$;:GOTO 1420
1410 IF II<= PB(I1)+LN2 THEN LPRINT TAB(TT+1);STRING$(A1,PHORLN$);
1420 TT=TT+A1+1
1430 IF I=GLEN THEN LPRINT TAB(TT-1);PDGLN$;
1440 IF I1=FACTORS AND II<=PB(I1)+LN1 AND I<>GLEN  THEN LPRINT TAB(TT);PVRTLN$;: GOTO 1470
1450 IF I1=FACTORS THEN GOTO 1470
1460 IF II<=PB(I1)+LN1 AND II > PB(I1+1)+LN1 THEN LPRINT TAB(TT);PVRTLN$;
1470 NEXT I1
1480 I=I+1
1490 LPRINT
1500 NEXT II
1510 LPRINT "0   - ";
1520 FOR I=1 TO FACTORS-1:LPRINT STRING$(A1,"-");"+";:NEXT:LPRINT STRING$(A1,"-")
1530 TT=7
1540 FOR I=1 TO FACTORS
1550 IF LEN(A$(I))>A1 THEN OP$=LEFT$(A$(I),A1) ELSE OP$=A$(I)
1560 LPRINT TAB(TT);OP$;
1570 TT=TT+A1+1
1580 NEXT I
1590 LPRINT
1600 LPRINT TAB(40-LEN(TITLE$)/2);TITLE$
1610 LPRINT PRESET$:LPRINT:LPRINT
1620 GOTO 990
TT+A