10 ' "THREEDEE/GRA" 26 ' BASICG SAMPLE PROGRAM FOR TRS-80 MODEL II HIRES GRAPHICS BOARD 27 ' From the TRS-80 Computer Graphics Operations Manual p. 165 28 ' Minor additions by Michael Haensel 20221007 40 ' 50 ' Object 60 ' The object of this program is to produce a three 70 ' dimensional bar graph representation of the gross 80 ' income for a company over a one year period. 90 ' 100 ' Variables 110 ' Vertical alphanumeric character 120 'BMSG$ Bottom message 130 'CHAR $ Disk file input field 140 'GI$ Gross income 150 'I Counter 160 'J Counter 170 'MN$ Month 180 'REC Record number of vertical character 190 'S1$ Single character of vertical message 200 'TILE$ Tile pattern for painting 210 'TTINC Total income for the year 220 'X X-coordinate of bar 230 'Y(i) Y-coordinate of bar 240 ' 250 'Input/output 260 'The program prompts you to enter the gross income, in 270 ' millions for each month. The program requires these 275 ' values to be between one and nine. 310 ' 320 'Set initial values 330 ' 340 CLS2 370 DIM Y(12),A(8),MN$(12) 380 DEFINT A 390 VMSG$=" Millions of dollars " 400 TMSG$="G r o s s I n c o m e F o r 1 9 8 0 " 410 BMSG$="M o n t h" 420 MN$(1)="January" 430 MN$(2)="February" 440 MN$(3)="March" 450 MN$(4)="April" 460 MN$(5)="May" 470 MN$(6)="June" 480 MN$(7)="July" 490 MN$(8)="August" 500 MN$(9)="September" 510 MN$(10)="October" 520 MN$(11)="November" 530 MN$(12)="December" 540 TILE$=CHR$(&H99)+CHR$(&H66) 550 X=-10 560 ' 570 'Input gross income, and calculate the Y-coordinate 580 ' 581 PRINT "3D Bar Chart" 582 PRINT "Do you want to:" 583 PRINT "1) Enter your own monthly values?" 584 PRINT "2) See a demo chart?" 585 A$=INKEY$ 586 IF A$ = "1" THEN DEMO = 1 ELSE IF A$ = "2" THEN DEMO = 2 ELSE 585 587 CLS 590 FOR I=1 TO 12 600 CLS 610 PRINT "Enter gross income in millions (1-9) for ";MN$(I) 620 PRINT "$_______ " 630 PRINT @ (0,0 ),"" 640 IF DEMO = 1 THEN LINE INPUT "$";GI$ 645 IF DEMO = 2 THEN GI$ = STR$(RND(9)) 650 Y(I)=205-20*VAL(GI$) 660 TTINC=TTINC+VAL(GI$) 670 NEXT I 680 CLS 2 690 ' 700 'Draw the graph and bars 710 ' 720 LINE (35,0)-(35,202) 730 LINE -(639,205) 740 FOR I =1 TO 12 760 X=X+50 770 LINE (X,Y(I))-(X+20,205),1,BF 780 LINE -(X+40,195) 790 LINE -(X+40,Y(I)-10) 800 LINE -(X+20,Y(I)-10) 810 LINE -(X,Y(I)) 820 LINE (X+20,Y(I))-(X+40,Y(I)-10) 830 PAINT(X+21,Y(I)+2),TILE$,1 840 NEXT I 850 ' 980 ' 990 'Print out the other display messages 1000 ' 1005 CLS 1010 PRINT @(21,5),"Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec" 1020 PRINT @(22,36), BMSG$ 1030 FOR I=1 TO 10 1040 IF I>9 THEN C=1 ELSE C=2 1050 PRINT @ (20-I*2,C),STR$(I);"-" 1060 NEXT I 1070 PRINT @(0,22),TMSG$ 1080 PRINT @(1,26),"(Total income is";TTINC;"million)" 1090 If INKEY$<>"" THEN 1090 ' FLUSH KEYBOARD BUFFER 1100 IF INKEY$="" THEN 1100 ' PRESS ANY KEY TO QUIT 1110 CLS2