Advertisement
metallaro1980

EXPOSURE VALUE CALCULATOR PRO

Jun 19th, 2014
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 2.72 KB | None | 0 0
  1. REM IT WORKS ONLY UNDER RFO BASIC! FOR ANDROID
  2.  
  3. FN.DEF log2 (valore)
  4. result = LOG(valore) / LOG(2)
  5. FN.rtn result
  6. FN.END
  7.  
  8. FN.DEF calculate(ev1, av2)
  9. pt = pow(av2,2)
  10. ev2 = log2(pt)
  11. rst = ev1- ev2
  12. IF rst < 0
  13. rst = ABS(rst)
  14. endif
  15. result = pow(2,rst)
  16. FN.rtn result
  17. FN.END
  18.  
  19. FN.DEF check(strnumber$)
  20. c = 0
  21. FOR i = 1 TO LEN(strnumber$)
  22. car$ = MID$(strnumber$, i, 1)
  23. IF car$ = "0"
  24. c = c + 1
  25. endif
  26. IF car$ = "1"
  27. c = c + 1
  28. endif
  29. IF car$ = "2"
  30. c = c + 1
  31. endif
  32. IF car$ = "3"
  33. c = c + 1
  34. endif
  35. IF car$ = "4"
  36. c = c + 1
  37. endif
  38. IF car$ = "5"
  39. c = c + 1
  40. endif
  41. IF car$ = "6"
  42. c = c + 1
  43. endif
  44. IF car$ = "7"
  45. c = c + 1
  46. endif
  47. IF car$ = "8"
  48. c = c + 1
  49. endif
  50. IF car$ = "9"
  51. c = c + 1
  52. endif
  53. IF car$ = "."
  54. c = c + 1
  55. endif
  56. NEXT
  57. IF c = LEN(strnumber$)
  58. FN.rtn 1
  59. endif
  60. IF c <> LEN(strnumber$)
  61. FN.rtn 0
  62. endif
  63. FN.END
  64.  
  65. start:
  66. array.load diaframmi[],1,1.2,1.4,1.7,1.8,2,2.4,2.8,3.3,3.4,4,4.8,5.6,6.7,8,9.5,11,13.0,16,19,22
  67. inizio:
  68. CLS
  69. switch = 0
  70.  
  71. INPUT "Diaframma a tutta apertura: ", av1
  72. ripeti:
  73. INPUT "Tempo a tutta apertura: ", temp1$
  74. IF LEN(temp1$) < 1
  75. GOTO ripeti
  76. endif
  77. temp1$=replace$(temp1$,"//", "/")
  78. IF RIGHT$(temp1$, 1) = "/"
  79. temp1$ = LEFT$(temp1$, LEN(temp1$) - 1)
  80. endif
  81. IF RIGHT$(temp1$, 1) = "."
  82. temp1$ = LEFT$(temp1$, LEN(temp1$) - 1)
  83. endif
  84. IF LEFT$(temp1$, 1) = "/"
  85. temp1$ = RIGHT$(temp1$, LEN(temp1$) - 1)
  86. endif
  87. FOR i = 1 TO LEN(temp1$)
  88. IF MID$(temp1$, i, 1) = "/"
  89. switch = 1
  90. strnum$ = MID$(temp1$, 1, i-1)
  91. strden$ = MID$(temp1$, i + 1, LEN(temp1$) - i)
  92. IF RIGHT$(strnum$, 1) = "."
  93. strnum$ = LEFT$(strnum$, LEN(strnum$) - 1)
  94. endif
  95. IF RIGHT$(strden$, 1) = "."
  96. strden$ = LEFT$(strden$, LEN(strden$) - 1)
  97. endif
  98. IF check(strnum$) = 0
  99. GOTO ripeti
  100. endif
  101. IF check(strden$) = 0
  102. GOTO ripeti
  103. endif
  104. num = VAL(strnum$)
  105. den = VAL(strden$)
  106. numint = INT(num)
  107. denint = INT(den)
  108. tempo1 = numint / denint
  109. Endif
  110. NEXT
  111.  
  112. IF switch = 1
  113.   ev1 = (pow(av1,2)) / tempo1
  114.   ev1 = log2(ev1)
  115.   array.length lngth, diaframmi[]
  116.  
  117.   FOR i = 1 TO lngth
  118.     av2 = diaframmi[i]
  119.     IF av2 <> av1
  120.       tempo2 = calculate(ev1,av2)
  121.       IF tempo2 < 2
  122.     tempo2 = 1 / tempo2
  123.     PRINT STR$(tempo2) + " sec @" + STR$(av2)
  124.       ELSE
  125.     PRINT "1/" + STR$(tempo2) + " sec @" + STR$(av2)
  126.       Endif
  127.     endif
  128.   NEXT
  129.  
  130.  
  131.  
  132. ELSEIF switch = 0
  133.   IF check(temp1$) = 0 THEN
  134.     GOTO ripeti
  135.   endif
  136.   tempo1 = VAL(temp1$)
  137.   ev1 = (av1 ^ 2) / tempo1
  138.   ev1 = log2(ev1)
  139.   array.length lngth, diaframmi[]
  140.   FOR i = 1 TO lngth
  141.     av2 = diaframmi[i]
  142.     IF av2 <> av1
  143.       tempo2 = calculate(ev1, av2)
  144.       PRINT STR$(tempo2) + " sec @" + STR$(av2)
  145.     endif
  146.   NEXT
  147. endif
  148.  
  149. PRINT "by Andrea Verdi ©"
  150. pause 20000
  151. INPUT "Exit? y/n", k$
  152. IF k$ = "y"
  153. END
  154. endif
  155. IF k$ = "Y"
  156. END
  157. endif
  158. GOTO inizio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement