home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / metrics.lbr / MEASURE.BZS / MEASURE.BAS
Encoding:
BASIC Source File  |  1993-10-26  |  5.5 KB  |  129 lines

  1. 10 DEFDBL A,K,X:DEFINT J,M,N,T:DIM A(20),K(20):T=7
  2. 20 PRINT CHR$(26):REM CLEAR SCREEN
  3. 30 PRINT"   *** MEASURE ***":PRINT:PRINT
  4. 31 REM  Written by JIM SCHENKEL 415/928-4445. MBASIC
  5. 32 REM  version 7/11/81 translated from original North
  6. 33 REM  Star Basic version donated to NorthStar Users'
  7. 34 REM  Group library in 1978.  NSBASIC uses BCD math.
  8. 35 REM  MBASIC doesn't, but double precision calculation
  9. 36 REM  should give accurate results to 6 places as printed.
  10. 37 REM  Data is from CRC HANDBOOK OF CHEMISTRY &
  11. 38 REM  PHYSICS (58th ed., 1978).  Good to 8 places.
  12. 39 REM  Comments welcome.
  13. 40 PRINT"Choose the number of the type of measurement involved"
  14. 50 PRINT:RESTORE 380:FOR J=1 TO T:READ A$:PRINT J;A$:NEXT
  15. 60 PRINT:INPUT M
  16. 70 IF M<1 OR M>7 OR INT(M)<>ABS(M) THEN 40
  17. 80 PRINT CHR$(26):PRINT"Choose the number of the units"
  18. 90 PRINT"you wish to have converted"
  19. 100 GOSUB 740:N1=0
  20. 110 READ A$:IF A$="" THEN 130
  21. 120 N1=N1+1:PRINT N1;A$:GOTO 110
  22. 130 PRINT:INPUT N
  23. 140 IF N<=N1 AND N>=1 AND INT(N)=ABS(N) THEN 160
  24. 150 PRINT"Sorry, try again":GOTO 100
  25. 160 GOSUB 740:FOR J=1 TO N:READ A$:NEXT:PRINT
  26. 170 PRINT"How many ";A$;:INPUT X:GOSUB 750:IF M=7 THEN 320
  27. 180 FOR I=1 TO N1-1:READ R:K(I)=R:NEXT
  28. 190 IF N<>1 THEN 210
  29. 200 FOR J=2 TO N1:A(J)=X/K(J-1):NEXT:GOTO 250
  30. 210 A(1)=X*K(N-1):FOR J=2 TO N1
  31. 220 IF J=N THEN 240
  32. 230 A(J)=A(1)/K(J-1)
  33. 240 NEXT J
  34. 250 FOR J=1 TO N:READ A$:NEXT
  35. 260 PRINT:PRINT X;" ";A$;" is equivalent to:":GOSUB 740
  36. 270 FOR I=1 TO N1:READ A$:IF I=N THEN 290
  37. 278 REM  O! in line 280 changes the calculated result to
  38. 279 REM  single precision.  Change to LPRINT for hardcopy.'
  39. 280 O!=A(I):PRINT O,A$
  40. 290 NEXT I
  41. 300 PRINT:PRINT"Again?":PRINT"1-same units  2-same type  3-different type"
  42. 310 Q$=INPUT$(1):ON VAL(Q$) GOTO 160,80,40:END
  43. 319 REM  Lines 320-370 deal with temperature (special case).
  44. 320 IF N=1 THEN 350
  45. 330 IF N=2 THEN 360
  46. 340 A(1)=X-273.16:A(2)=A(1)*1.8+32:GOTO 370
  47. 350 A(3)=X+273.16:A(2)=X*1.8+32:GOTO 370
  48. 360 A(1)=(X-32)/1.8:A(3)=A(1)+273.16
  49. 370 RESTORE 720:GOTO 250
  50. 379 REM  Types of measurement follow:
  51. 380 DATA " length"," area"," volume"," mass"
  52. 390 DATA " energy"," velocity"," temperature"
  53. 399 REM  Data areas follow, beginning with constants for length.
  54. 400 DATA 100,1e5,2.54,30.48,91.44,1.609344e5
  55. 410 DATA 1.852e5,1e-8,9.46055e17
  56. 420 DATA centimeters, meters, kilometers, inches
  57. 430 DATA feet, yards, miles, naut. miles (Int'l)
  58. 440 DATA angstroms, light years, ""
  59. 450 DATA 1e4,1e10,6.4516,929.0304,8361.2736
  60. 460 DATA 25899881000#,40468564#
  61. 470 DATA square centimeters, square meters
  62. 480 DATA square kilometers, square inches
  63. 490 DATA square feet, square yards, square miles
  64. 500 DATA acres, ""
  65. 510 DATA 1000!,1E+06,16.387064#,28316.847#,764554.86#,29.5735
  66. 520 DATA 473.1764700000001#,946.3529400000001#,3785.4118#,4546.09,158987!
  67. 530 DATA cubic centimeters, liters, cubic meters
  68. 540 DATA cubic inches, cubic feet, cubic yards
  69. 550 DATA fluid ounces, fluid pints, fluid quarts
  70. 560 DATA gallons, Imperial gallons, barrels (oil),""
  71. 570 DATA 1e3,1e6,28.349523,453.59237,9.0718474e5
  72. 580 DATA 31.103486,373.24182,980.665
  73. 590 DATA grams, kilograms, metric tons
  74. 600 DATA ounces (avoirdupois),pounds (avoirdupois)
  75. 610 DATA short tons, Troy ounces, Troy pounds, dynes, ""
  76. 620 DATA 3.9683207e-3,9.2744135e-3,1.28408e-3,9.48451e-4
  77. 630 DATA 2546.14,3404.6205,9.48451e-11,2.8736047e5,9.30113e-8
  78. 640 DATA BTU, calories
  79. 650 DATA kilogram meters, foot pounds
  80. 660 DATA joules, horsepower hours, kilowatt hours
  81. 670 DATA ergs, tons of refrigeration, gram centimeters, ""
  82. 680 DATA 27.78,2.54,30.48,.508,44.7
  83. 690 DATA centimeters per second, kilometers per hour
  84. 700 DATA inches per second, feet per second
  85. 710 DATA feet per minute, miles per hour, ""
  86. 720 DATA degrees centigrade, degrees Farenheit
  87. 730 DATA degrees Kelvin, ""
  88. 740 ON M GOTO 760,770,780,790,800,810,820
  89. 750 ON M GOTO 830,840,850,860,870,880,890
  90. 759 REM  Lines 760-820 reset to proper constants.
  91. 760 RESTORE 420:RETURN
  92. 770 RESTORE 470:RETURN
  93. 780 RESTORE 530:RETURN
  94. 790 RESTORE 590:RETURN
  95. 800 RESTORE 640:RETURN
  96. 810 RESTORE 690:RETURN
  97. 820 RESTORE 720:RETURN
  98. 829 REM  Lines 830-890 reset to proper unit names.
  99. 830 RESTORE 400:RETURN
  100. 840 RESTORE 450:RETURN
  101. 850 RESTORE 510:RETURN
  102. 860 RESTORE 570:RETURN
  103. 870 RESTORE 620:RETURN
  104. 880 RESTORE 680:RETURN
  105. 890 RETURN
  106. 900 REM  Additional types of measurement can be
  107. 901 REM  added by the following steps:
  108. 902 REM    --  Increase the number of types of
  109. 903 REM    measurements (T, line 10).
  110. 904 REM    --  Add the name of the type of measurement
  111. 905 REM    to the data statement on line 390, or put
  112. 906 REM    in a new data line at, e.g., 395.  Note the
  113. 907 REM    leading space.
  114. 908 REM    --  Add appropriate jump vectors to lines
  115. 909 REM    740 and 750 (e.g., to lines 825 and 895).
  116. 910 REM    --  Add line restoring data area for the
  117. 911 REM    numeric constants (e.g., at line 825).
  118. 912 REM    --  Add line restoring data area for the
  119. 913 REM    unit name strings (e.g., at line 895).
  120. 914 REM    --  Create appropriate data lines.
  121. 915 REM    Note that there should be one more unit name
  122. 916 REM    in the list than there are constants.  Each
  123. 917 REM    calculation first converts everything into
  124. 918 REM    the first units on the list (e.g., centimeters)
  125. 919 REM    and then multiplies by the constants to 
  126. 920 REM    arrive at the other values.
  127. 921 REM    --  Be sure that the last data item in the
  128. 922 REM    list of unit names is the dummy data "".
  129. thó_4úE909K9,u6)9' ~6 µä?3!÷*}(&ò4!93!5+31E}(&ßL2═hì¿.+äΓ2!É92ùαí¡ 9KΓ0æ!d║C5═h¬I5!d▀½3═U5[5 ▄&▀½3&W6    ├6É