home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
pcmag
/
vol4n13.arc
/
BAR1.BAS
next >
Wrap
BASIC Source File
|
1985-03-29
|
977b
|
31 lines
'Figure 1:(longest line=60; stat 67% in 2-column width)
0 '** Program 1 **
10 INF=1.7E+38 'Infinity
20 SCREEN 1:CLS 'Set graphics mode
30 INPUT"Number of bars";N:IF N<2 THEN 30
40 DIM S(N) 'Set space for N values
50 MAX=-INF 'Set maximum to minus infinity
60 MIN=INF 'Set minimum to infinity
70 FOR I=1 TO N
80 INPUT"Bar value";S(I)
90 IF S(I)>MAX THEN MAX=S(I)
100 IF S(I)<MIN THEN MIN=S(I)
110 NEXT
120 IF MIN=MAX THEN PRINT"All the numbers are the same.":END
130 CLS
140 LINE(0,0)-(0,199) 'Y-axis
150 LINE(0,199)-(319,199) 'X-axis
160 DX=320/N 'Width of one column
170 WB=DX*.8 'Width of one bar
180 SPB=DX*.5-(WB*.5) 'Starting point of first bar
190 FACTOR=190/(MAX-MIN) 'Scaling factor
200 FOR I=1 TO N
210 HEIGHT=(S(I)-MIN)*FACTOR 'Height of bar
220 LINE(SPB,190-HEIGHT)-(SPB+WB,198),2,BF
230 LINE(SPB,190-HEIGHT)-(SPB+WB,198),3,B
240 SPB=SPB+DX
250 NEXT
260 W$=INPUT$(1)