home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1985 / 13 / bar1.bas next >
BASIC Source File  |  1985-03-29  |  977b  |  31 lines

  1. 'Figure 1:(longest line=60; stat 67% in 2-column width)
  2.  
  3.  
  4.   0 '** Program 1 **
  5.  10 INF=1.7E+38   'Infinity
  6.  20 SCREEN 1:CLS   'Set graphics mode
  7.  30 INPUT"Number of bars";N:IF N<2 THEN 30
  8.  40 DIM S(N)    'Set space for N values
  9.  50 MAX=-INF    'Set maximum to minus infinity
  10.  60 MIN=INF     'Set minimum to infinity
  11.  70 FOR I=1 TO N
  12.  80   INPUT"Bar value";S(I)
  13.  90   IF S(I)>MAX THEN MAX=S(I)
  14. 100   IF S(I)<MIN THEN MIN=S(I)
  15. 110 NEXT
  16. 120 IF MIN=MAX THEN PRINT"All the numbers are the same.":END
  17. 130 CLS
  18. 140 LINE(0,0)-(0,199)       'Y-axis
  19. 150 LINE(0,199)-(319,199)   'X-axis
  20. 160 DX=320/N         'Width of one column
  21. 170 WB=DX*.8         'Width of one bar
  22. 180 SPB=DX*.5-(WB*.5)  'Starting point of first bar
  23. 190 FACTOR=190/(MAX-MIN)  'Scaling factor
  24. 200 FOR I=1 TO N
  25. 210   HEIGHT=(S(I)-MIN)*FACTOR  'Height of bar
  26. 220   LINE(SPB,190-HEIGHT)-(SPB+WB,198),2,BF
  27. 230   LINE(SPB,190-HEIGHT)-(SPB+WB,198),3,B
  28. 240   SPB=SPB+DX
  29. 250 NEXT
  30. 260 W$=INPUT$(1)
  31.