-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPIECHART.BAS
78 lines (78 loc) · 2.77 KB
/
PIECHART.BAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
940 REM The IBM Personal Computer Piechart
950 REM Version 1.10 (C)Copyright IBM Corp 1981, 1982
960 REM Licensed Material - Program Property of IBM
975 DEF SEG
980 SAMPLES$="NO"
990 GOTO 1010
1000 SAMPLES$="YES"
1010 KEY OFF:SCREEN 0,1:COLOR 15,0,0:WIDTH 40:CLS:LOCATE 5,19:PRINT "IBM"
1020 LOCATE 7,12,0:PRINT "Personal Computer"
1030 COLOR 10,0:LOCATE 10,9,0:PRINT CHR$(213)+STRING$(21,205)+CHR$(184)
1040 LOCATE 11,9,0:PRINT CHR$(179)+" PIECHART "+CHR$(179)
1050 LOCATE 12,9,0:PRINT CHR$(179)+STRING$(21,32)+CHR$(179)
1060 LOCATE 13,9,0:PRINT CHR$(179)+" Version 1.10 "+CHR$(179)
1070 LOCATE 14,9,0:PRINT CHR$(212)+STRING$(21,205)+CHR$(190)
1080 COLOR 15,0:LOCATE 17,4,0:PRINT "(C) Copyright IBM Corp 1981, 1982"
1090 COLOR 14,0:LOCATE 23,7,0:PRINT "Press space bar to continue"
1100 IF INKEY$<>"" THEN GOTO 1100
1110 CMD$ = INKEY$
1120 IF CMD$ = "" THEN GOTO 1110
1130 IF CMD$ = CHR$(27) THEN GOTO 1298
1140 IF CMD$ = " " THEN GOTO 1160
1150 GOTO 1110
1160 DEF SEG=0
1170 IF (PEEK(&H410) AND &H30)<>&H30 THEN DEF SEG:GOTO 1291
1180 WIDTH 80:CLS:LOCATE 3,1
1190 PRINT "HOLD IT!"
1200 PRINT "YOU'RE NOT USING THE COLOR/GRAPHICS MONITOR ADAPTER!"
1210 PRINT "THIS PROGRAM USES GRAPHICS AND REQUIRES THAT ADAPTER."
1220 PRINT "PRESS THE SPACE BAR TO CONTINUE."
1230 DEF SEG
1240 IF INKEY$<>"" THEN GOTO 1240
1250 CMD$ = INKEY$
1260 IF CMD$ = "" THEN GOTO 1250
1270 IF CMD$ = CHR$(27) THEN GOTO 1298
1280 IF CMD$ = " " THEN GOTO 1298
1290 GOTO 1250
1291 KEY OFF
1292 ON ERROR GOTO 1295
1293 PLAY "p16"
1294 GOTO 1300
1295 COLOR 31,0,0
1296 PRINT "THIS PROGRAM REQUIRES ADVANCED BASIC -- USE COMMAND 'BASICA'":COLOR 15,0,0:FOR I=1 TO 9000:NEXT: RESUME 1298
1298 ON ERROR GOTO 0
1299 SCREEN 0,1:IF SAMPLES$="YES" THEN CHAIN"samples",1000 ELSE COLOR 7,0,0:CLS:END
1300 DIM R(100),A$(100)
1400 CLS
1420 SCREEN 1,0:COLOR 8,0
1440 LR=50:SR=44
1450 INPUT "title of chart";T$
1460 INPUT "how many items in chart";N
1470 S=0
1480 FOR I=1 TO N
1490 INPUT "numeric value ,name";R(I),A$(I)
1500 S=S+R(I)
1510 NEXT
1520 FOR I=1 TO N:R(I)=R(I)/S:NEXT
1530 A2=0
1540 CLS
1550 LOCATE 2,20-LEN(T$)/2:PRINT T$
1560 LINE (8*(19.5-LEN(T$)/2)-8,7)-(8*(19.5+LEN(T$)/2) ,16),3,B
1570 FOR C=1 TO N
1580 A1=A2:A2=A2+R(C)*2*3.1415926#
1590 AA=(A1+A2)/2
1600 CX=160+COS(AA)*(LR-SR)
1610 CY=100-SIN(AA)*(LR-SR)
1620 CIRCLE (CX,CY),SR,1,-A1-.001,-A2
1630 PAINT (CX+COS(AA)*.8*SR,CY-SIN(AA)*.8*SR),C MOD 4,1
1640 LX=CX+COS(AA)*(16+SR)-4*LEN(A$(C)):LY=CY-SIN(AA)*(SR+16)
1650 LOCATE 1+(LY\8),1+(LX\8):PRINT A$(C);
1660 LINE ((LX\8)*8,8*((LY\8)+1))-((LX\8)*8+8*LEN(A$(C)),8*((LY\8)+1)),1
1670 NEXT C
1680 LOCATE 23,1
1700 PRINT"Another Chart? (Y or N)";
1710 A$=INKEY$:IF A$="" THEN 1710
1730 IF A$="N" OR A$="n" THEN 1298
1740 IF A$="Y" OR A$="y" THEN 1400
1750 GOTO 1680