Author Topic: Calculator  (Read 7774 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Calculator
« Reply #30 on: July 30, 2020, 12:42:36 pm »
B+, X^Y is what I made EXP to begin with because I thought that's what the EXP button does lol. But I changed it to how you wanted me to yesterday. As for the rest of the stuff, I personally don't have a need for them. I never use the memory buttons or anything else actually. As for the X^Y, probably sometime. Today I'm probably going to take a break on it. I hurt my wrist the other day when I fell down outside and today it's not doing too great.
Thanks for the suggestions though. If I really want to dive into all those things sometime, I might.

Spriggs, yes I've thought about adding keyboard use to it, like everything on the number pad. And maybe S = Sine, C = Cosine, T = Tangent, etc. It shouldn't be too hard with just INKEY$ so I probably will soon. Thanks for the suggestion.

If any of you want to tinker with this for yourself on your own mods, go right ahead. It's for all of us.
 


Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Calculator
« Reply #31 on: July 30, 2020, 03:19:34 pm »
I just added keyboard control to everything. :) I also made a Help page that describes what all the keys do. Press Esc to get to the Help page. It says this in the _TITLE as well. It's pretty neat how when you press a key on the keyboard for something, it shows the key on the calculator being pressed. When using the Number Pad (which you can use that or the others), make sure you have Num Lock turned on.

Code: QB64: [Select]
  1. 'Calculator
  2. 'By SierraKen on July 30, 2020.
  3. '------------------------------
  4. 'This is my very first regular calculator.
  5. 'Thank you to B+ and TempodiBasic for the help and everyone for the inspiration!
  6. 'This was a 4 day project and I've wanted to make this all my life. Ever since I was real little
  7. 'playing around with my parents' calculator.
  8. 'Thank you Dav for the icon code!
  9. 'Added Clipboard by clicking the output number.
  10. 'Added Rad2Deg (and Deg2Rad), second power, Base 10 Logarithm, and Pi buttons.
  11. 'Added 1/x, x/2, exp, postive or negative.
  12. 'Added keyboard control and help page.
  13.  
  14. 'Load the icon - call this somewhere near the top of your program
  15. _ICON BASIMAGE1&
  16.  
  17. _TITLE "Calculator - Esc for help."
  18. SCREEN _NEWIMAGE(400, 500, 32)
  19. begin:
  20. num$ = ""
  21. c = 0
  22. a = 0: s = 0: t = 0: d = 0
  23. 'Setup calculator
  24. LINE (50, 25)-(265, 50), _RGB32(255, 255, 255), B
  25. LINE (50, 75)-(350, 350), _RGB32(255, 255, 255), B
  26. 'Buttons
  27. FOR buttony = 75 TO 405 STEP 55
  28.     FOR buttonx = 50 TO 275 STEP 75
  29.         FOR bb = 0 TO 10
  30.             c = c + 10
  31.             LINE (buttonx + bb, buttony + bb)-(buttonx + 75 - bb, buttony + 55 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
  32.         NEXT bb
  33.         PAINT (buttonx + 12, buttony + 12), _RGB32(100 + c, 100 + c, 100 + c)
  34.         c = 0
  35.     NEXT buttonx
  36. NEXT buttony
  37. buttonx = 275: buttony = 20
  38. 'Green C Button
  39. FOR bb = 0 TO 10
  40.     c = c + 10
  41.     LINE (buttonx + bb, buttony + bb)-(buttonx + 75 - bb, buttony + 55 - bb), _RGB32(50, 100 + c, 50), B
  42. NEXT bb
  43. PAINT (buttonx + 12, buttony + 12), _RGB32(50, 100 + c, 50)
  44. COLOR _RGB32(0, 0, 0), _RGB32(50, 100 + c, 50)
  45. _PRINTSTRING (50, 5), "Rad"
  46. wer:
  47. 'Label Buttons
  48. _PRINTSTRING (312, 47), "C"
  49. COLOR _RGB32(0, 0, 0), _RGB32(210, 210, 210)
  50. _PRINTSTRING (87, 102), CHR$(251) 'square root
  51. _PRINTSTRING (152, 102), "sin"
  52. _PRINTSTRING (227, 102), "cos"
  53. _PRINTSTRING (302, 102), "tan"
  54. _PRINTSTRING (87, 157), "7"
  55. _PRINTSTRING (162, 157), "8"
  56. _PRINTSTRING (237, 157), "9"
  57. _PRINTSTRING (312, 157), "/"
  58. _PRINTSTRING (87, 212), "4"
  59. _PRINTSTRING (162, 212), "5"
  60. _PRINTSTRING (237, 212), "6"
  61. _PRINTSTRING (312, 212), "x"
  62. _PRINTSTRING (87, 267), "1"
  63. _PRINTSTRING (162, 267), "2"
  64. _PRINTSTRING (237, 267), "3"
  65. _PRINTSTRING (312, 267), "-"
  66. _PRINTSTRING (87, 322), "0"
  67. _PRINTSTRING (162, 322), "."
  68. _PRINTSTRING (237, 322), "="
  69. _PRINTSTRING (312, 322), "+"
  70. _PRINTSTRING (79, 377), "deg"
  71. _PRINTSTRING (162, 377), "x" + CHR$(253) 'second power
  72. _PRINTSTRING (227, 377), "log"
  73. _PRINTSTRING (307, 377), "Pi"
  74. _PRINTSTRING (79, 432), "1/x"
  75. _PRINTSTRING (152, 432), "x/2"
  76. _PRINTSTRING (227, 432), "exp"
  77. _PRINTSTRING (312, 432), CHR$(241) 'Postive or Negative
  78.  
  79. COLOR _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  80.     _LIMIT 20
  81.     a$ = INKEY$
  82.     IF a$ <> "" THEN mousex = 0: mousey = 0: mouseLeftButton = 0
  83.     IF a$ = CHR$(27) THEN GOTO help:
  84.     IF a$ = CHR$(3) THEN a$ = "": GOTO clip: 'Ctrl+C copies to clipboard.
  85.     IF a$ = CHR$(8) THEN a$ = "": GOTO delete: 'Back Space deletes output.
  86.     IF a$ = "p" OR a$ = "P" OR a$ = "n" OR a$ = "N" THEN a$ = "": GOTO posneg: 'Positive or Negative
  87.     IF a$ = "f" OR a$ = "F" THEN a$ = "": GOTO fraction:
  88.     IF a$ = "h" OR a$ = "H" THEN a$ = "": GOTO half:
  89.     IF a$ = "e" OR a$ = "E" THEN a$ = "": GOTO expcommand:
  90.     IF a$ = "r" OR a$ = "R" OR a$ = "d" OR a$ = "D" THEN a$ = "": GOTO radanddeg:
  91.     IF a$ = "u" OR a$ = "U" THEN a$ = "": GOTO squared:
  92.     IF a$ = "l" OR a$ = "L" THEN a$ = "": GOTO logarithm:
  93.     IF a$ = "i" OR a$ = "I" THEN a$ = "": GOTO pi:
  94.     IF a$ = "q" OR a$ = "Q" THEN a$ = "": GOTO squareroot:
  95.     IF a$ = "s" OR a$ = "S" THEN a$ = "": GOTO sine:
  96.     IF a$ = "c" OR a$ = "C" THEN a$ = "": GOTO cosine:
  97.     IF a$ = "t" OR a$ = "T" THEN a$ = "": GOTO tangent:
  98.     IF a$ = "1" THEN a$ = "": GOTO one:
  99.     IF a$ = "2" THEN a$ = "": GOTO two:
  100.     IF a$ = "3" THEN a$ = "": GOTO three:
  101.     IF a$ = "4" THEN a$ = "": GOTO four:
  102.     IF a$ = "5" THEN a$ = "": GOTO five:
  103.     IF a$ = "6" THEN a$ = "": GOTO six:
  104.     IF a$ = "7" THEN a$ = "": GOTO seven:
  105.     IF a$ = "8" THEN a$ = "": GOTO eight:
  106.     IF a$ = "9" THEN a$ = "": GOTO nine:
  107.     IF a$ = "0" THEN a$ = "": GOTO zero2:
  108.     IF a$ = "." THEN a$ = "": GOTO decimal:
  109.     IF a$ = "=" THEN a$ = "": GOTO equals:
  110.     IF a$ = "+" THEN a$ = "": GOTO add:
  111.     IF a$ = "-" THEN a$ = "": GOTO subtract:
  112.     IF a$ = "*" OR a$ = "x" OR a$ = "X" THEN a$ = "": GOTO multiply:
  113.     IF a$ = "/" THEN a$ = "": GOTO divide:
  114.  
  115.         mousex = _MOUSEX
  116.         mousey = _MOUSEY
  117.         mouseLeftButton = _MOUSEBUTTON(1)
  118.     LOOP
  119.     IF mouseLeftButton THEN
  120.         mouseLeftButton = 0
  121.  
  122.         'Clipboard
  123.         IF mousex > 50 AND mousex < 265 AND mousey > 25 AND mousey < 50 THEN
  124.             clip:
  125.             COLOR _RGB32(0, 255, 0), _RGB32(0, 0, 0)
  126.             _PRINTSTRING (55, 30), num$
  127.             _DELAY 1
  128.             num2$ = _TRIM$(num$)
  129.             _CLIPBOARD$ = num2$
  130.             COLOR _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  131.             _PRINTSTRING (55, 30), num$
  132.         END IF
  133.  
  134.         'Clear
  135.         IF mousex > 275 AND mousex < 350 AND mousey > 20 AND mousey < 75 THEN
  136.             delete:
  137.             a = 0: s = 0: t = 0: d = 0: num$ = ""
  138.             _PRINTSTRING (55, 30), "                          "
  139.             buttonx = 275: buttony = 20
  140.             GOSUB zero:
  141.         END IF
  142.  
  143.         '1/x
  144.         IF mousex > 50 AND mousex < 125 AND mousey > 405 AND mousey < 460 THEN
  145.             fraction:
  146.             num = VAL(num$)
  147.             IF num = 0 THEN GOTO skipthis:
  148.             num = 1 / num
  149.             num$ = STR$(num)
  150.             skipthis:
  151.             buttonx = 50: buttony = 405
  152.             GOSUB press:
  153.             GOSUB number:
  154.         END IF
  155.  
  156.         'x/2
  157.         IF mousex > 126 AND mousex < 200 AND mousey > 405 AND mousey < 460 THEN
  158.             half:
  159.             num = VAL(num$)
  160.             num = num / 2
  161.             num$ = STR$(num)
  162.             buttonx = 126: buttony = 405
  163.             GOSUB press:
  164.             GOSUB number2:
  165.         END IF
  166.  
  167.         'EXP
  168.         IF mousex > 200 AND mousex < 275 AND mousey > 405 AND mousey < 460 THEN
  169.             expcommand:
  170.             _PRINTSTRING (55, 30), "                          "
  171.             num = EXP(VAL(num$))
  172.             num$ = STR$(num)
  173.             buttonx = 200: buttony = 405
  174.             GOSUB number2:
  175.             GOSUB press:
  176.         END IF
  177.  
  178.         'Postive or Negative
  179.         IF mousex > 275 AND mousex < 350 AND mousey > 405 AND mousey < 460 THEN
  180.             posneg:
  181.             IF VAL(num$) < 0 THEN
  182.                 num = -VAL(num$)
  183.                 num$ = STR$(num)
  184.                 GOTO skipplusnegative:
  185.             END IF
  186.             num$ = "-" + num$
  187.             skipplusnegative:
  188.             buttonx = 275: buttony = 405
  189.             GOSUB press:
  190.             GOSUB number:
  191.         END IF
  192.  
  193.         'Radians and Degrees
  194.         IF mousex > 50 AND mousex < 125 AND mousey > 350 AND mousey < 405 THEN
  195.             radanddeg:
  196.             deg = deg + 1
  197.             IF deg = 2 THEN GOTO deg2rad:
  198.             COLOR _RGB32(0, 0, 0), _RGB32(210, 210, 210)
  199.             _PRINTSTRING (79, 377), "rad"
  200.             COLOR _RGB32(0, 0, 0), _RGB32(50, 100 + c, 50)
  201.             _PRINTSTRING (50, 5), "Deg"
  202.             num = VAL(num$)
  203.             num = _R2D(num)
  204.             num$ = STR$(num)
  205.             GOTO skipdeg2rad:
  206.             deg2rad:
  207.             deg = 0
  208.             COLOR _RGB32(0, 0, 0), _RGB32(210, 210, 210)
  209.             _PRINTSTRING (79, 377), "deg"
  210.             COLOR _RGB32(0, 0, 0), _RGB32(50, 100 + c, 50)
  211.             _PRINTSTRING (50, 5), "Rad"
  212.             num = VAL(num$)
  213.             num = _D2R(num)
  214.             num$ = STR$(num)
  215.             skipdeg2rad:
  216.             buttonx = 50: buttony = 350
  217.             GOSUB press:
  218.             GOSUB number:
  219.         END IF
  220.  
  221.         'Second Power
  222.         IF mousex > 126 AND mousex < 200 AND mousey > 350 AND mousey < 405 THEN
  223.             squared:
  224.             num = VAL(num$)
  225.             num = num ^ 2
  226.             num$ = STR$(num)
  227.             buttonx = 126: buttony = 350
  228.             GOSUB press:
  229.             GOSUB number:
  230.         END IF
  231.  
  232.         'logarithm
  233.         IF mousex > 200 AND mousex < 275 AND mousey > 350 AND mousey < 405 THEN
  234.             logarithm:
  235.             num = VAL(num$)
  236.             IF num = 0 THEN GOTO skiplog:
  237.             IF num < 0 THEN GOTO skiplog:
  238.             num = LOG(num)
  239.             num$ = STR$(num)
  240.             skiplog:
  241.             buttonx = 200: buttony = 350
  242.             GOSUB press:
  243.             GOSUB number:
  244.         END IF
  245.  
  246.         'Pi
  247.         IF mousex > 275 AND mousex < 350 AND mousey > 350 AND mousey < 405 THEN
  248.             pi:
  249.             num = _PI
  250.             num$ = STR$(num)
  251.             buttonx = 275: buttony = 350
  252.             GOSUB press:
  253.             GOSUB number:
  254.         END IF
  255.  
  256.         'Square Root
  257.         IF mousex > 50 AND mousex < 125 AND mousey > 75 AND mousey < 130 THEN
  258.             squareroot:
  259.             IF num < 0 THEN GOTO skip1:
  260.             num = VAL(num$)
  261.             num = SQR(num)
  262.             num$ = STR$(num)
  263.             skip1:
  264.             buttonx = 50: buttony = 75
  265.             GOSUB press:
  266.             GOSUB number:
  267.         END IF
  268.  
  269.         'Sine
  270.         IF mousex > 126 AND mousex < 200 AND mousey > 75 AND mousey < 130 THEN
  271.             sine:
  272.             IF deg = 1 THEN num = SIN(_D2R(VAL(num$)))
  273.             IF deg = 0 THEN num = SIN(num)
  274.             num$ = STR$(num)
  275.             buttonx = 126: buttony = 75
  276.             GOSUB press:
  277.             GOSUB number:
  278.         END IF
  279.  
  280.         'Cosine
  281.         IF mousex > 200 AND mousex < 275 AND mousey > 75 AND mousey < 130 THEN
  282.             cosine:
  283.             IF deg = 1 THEN num = COS(_D2R(VAL(num$)))
  284.             IF deg = 0 THEN num = COS(num)
  285.             num$ = STR$(num)
  286.             buttonx = 200: buttony = 75
  287.             GOSUB press:
  288.             GOSUB number:
  289.         END IF
  290.  
  291.         'Tangent
  292.         IF mousex > 275 AND mousex < 350 AND mousey > 75 AND mousey < 130 THEN
  293.             tangent:
  294.             IF deg = 1 THEN num = TAN(_D2R(VAL(num$)))
  295.             IF deg = 0 THEN num = TAN(num)
  296.             num$ = STR$(num)
  297.             buttonx = 275: buttony = 75
  298.             GOSUB press:
  299.             GOSUB number:
  300.         END IF
  301.  
  302.         'Number Buttons
  303.         IF mousex > 50 AND mousex < 125 AND mousey > 130 AND mousey < 185 THEN
  304.             seven:
  305.             num$ = num$ + "7"
  306.             IF n = 1 THEN num$ = "-" + num$: n = 0
  307.             buttonx = 50: buttony = 130
  308.             GOSUB press:
  309.             GOSUB number:
  310.         END IF
  311.         IF mousex > 126 AND mousex < 200 AND mousey > 130 AND mousey < 185 THEN
  312.             eight:
  313.             num$ = num$ + "8"
  314.             IF n = 1 THEN num$ = "-" + num$: n = 0
  315.             buttonx = 126: buttony = 130
  316.             GOSUB press:
  317.             GOSUB number:
  318.         END IF
  319.         IF mousex > 200 AND mousex < 275 AND mousey > 130 AND mousey < 185 THEN
  320.             nine:
  321.             num$ = num$ + "9"
  322.             IF n = 1 THEN num$ = "-" + num$: n = 0
  323.             buttonx = 200: buttony = 130
  324.             GOSUB press:
  325.             GOSUB number:
  326.         END IF
  327.         IF mousex > 50 AND mousex < 125 AND mousey > 185 AND mousey < 240 THEN
  328.             four:
  329.             num$ = num$ + "4"
  330.             IF n = 1 THEN num$ = "-" + num$: n = 0
  331.             buttonx = 50: buttony = 185
  332.             GOSUB press:
  333.             GOSUB number:
  334.         END IF
  335.         IF mousex > 126 AND mousex < 200 AND mousey > 185 AND mousey < 240 THEN
  336.             five:
  337.             num$ = num$ + "5"
  338.             IF n = 1 THEN num$ = "-" + num$: n = 0
  339.             buttonx = 126: buttony = 185
  340.             GOSUB press:
  341.             GOSUB number:
  342.         END IF
  343.         IF mousex > 200 AND mousex < 275 AND mousey > 185 AND mousey < 240 THEN
  344.             six:
  345.             num$ = num$ + "6"
  346.             IF n = 1 THEN num$ = "-" + num$: n = 0
  347.             buttonx = 200: buttony = 185
  348.             GOSUB press:
  349.             GOSUB number:
  350.         END IF
  351.         IF mousex > 50 AND mousex < 125 AND mousey > 240 AND mousey < 295 THEN
  352.             one:
  353.             num$ = num$ + "1"
  354.             IF n = 1 THEN num$ = "-" + num$: n = 0
  355.             buttonx = 50: buttony = 240
  356.             GOSUB press:
  357.             GOSUB number:
  358.         END IF
  359.         IF mousex > 126 AND mousex < 200 AND mousey > 240 AND mousey < 295 THEN
  360.             two:
  361.             num$ = num$ + "2"
  362.             IF n = 1 THEN num$ = "-" + num$: n = 0
  363.             buttonx = 126: buttony = 240
  364.             GOSUB press:
  365.             GOSUB number:
  366.         END IF
  367.         IF mousex > 200 AND mousex < 275 AND mousey > 240 AND mousey < 295 THEN
  368.             three:
  369.             num$ = num$ + "3"
  370.             IF n = 1 THEN num$ = "-" + num$: n = 0
  371.             buttonx = 200: buttony = 240
  372.             GOSUB press:
  373.             GOSUB number:
  374.         END IF
  375.         IF mousex > 50 AND mousex < 125 AND mousey > 295 AND mousey < 350 THEN
  376.             zero2:
  377.             num$ = num$ + "0"
  378.             IF n = 1 THEN num$ = "-" + num$: n = 0
  379.             buttonx = 50: buttony = 295
  380.             GOSUB press:
  381.             GOSUB number:
  382.         END IF
  383.  
  384.         'Decimal
  385.         IF mousex > 126 AND mousex < 200 AND mousey > 295 AND mousey < 350 THEN
  386.             decimal:
  387.             buttonx = 126: buttony = 295
  388.             FOR check = 1 TO LEN(num$)
  389.                 IF MID$(num$, check, 1) = "." THEN GOTO skipdec:
  390.             NEXT check
  391.             num$ = num$ + "."
  392.             _PRINTSTRING (55, 30), num$
  393.             skipdec:
  394.             GOSUB press:
  395.         END IF
  396.  
  397.         'Equals
  398.         IF mousex > 200 AND mousex < 275 AND mousey > 295 AND mousey < 350 THEN
  399.             equals:
  400.             IF a = 1 THEN num = VAL(oldnum$) + VAL(num$): a = 0
  401.             IF s = 1 THEN num = VAL(oldnum$) - VAL(num$): s = 0
  402.             IF t = 1 THEN num = VAL(oldnum$) * VAL(num$): t = 0
  403.             IF d = 1 THEN num = VAL(oldnum$) / VAL(num$): d = 0
  404.             buttonx = 200: buttony = 295
  405.             GOSUB press:
  406.             GOSUB number2:
  407.         END IF
  408.  
  409.         'Add
  410.         IF mousex > 275 AND mousex < 350 AND mousey > 295 AND mousey < 350 THEN
  411.             add:
  412.             IF a = 0 THEN
  413.                 d = 0: a = 1: s = 0: t = 0
  414.                 oldnum$ = num$
  415.                 _PRINTSTRING (55, 30), "                          "
  416.                 num$ = ""
  417.                 GOTO nex4:
  418.             END IF
  419.             IF a = 1 THEN
  420.                 num = VAL(oldnum$) + VAL(num$)
  421.                 a = 0
  422.             END IF
  423.             GOSUB number2:
  424.             nex4:
  425.             buttonx = 275: buttony = 295
  426.             GOSUB press:
  427.         END IF
  428.  
  429.         'Subtract
  430.         IF mousex > 275 AND mousex < 350 AND mousey > 240 AND mousey < 295 THEN
  431.             subtract:
  432.             IF s = 0 THEN
  433.                 IF num$ = "0" OR num$ = "" OR num = 0 THEN n = 1: GOTO nex3:
  434.                 d = 0: a = 0: s = 1: t = 0
  435.                 oldnum$ = num$
  436.                 _PRINTSTRING (55, 30), "                          "
  437.                 num$ = ""
  438.                 GOTO nex3:
  439.             END IF
  440.             IF s = 1 THEN
  441.                 num = VAL(oldnum$) - VAL(num$)
  442.                 s = 0
  443.             END IF
  444.             GOSUB number2:
  445.             nex3:
  446.             buttonx = 275: buttony = 240
  447.             GOSUB press:
  448.         END IF
  449.  
  450.         'Multiply
  451.         IF mousex > 275 AND mousex < 350 AND mousey > 185 AND mousey < 240 THEN
  452.             multiply:
  453.             IF t = 0 THEN
  454.                 d = 0: a = 0: s = 0: t = 1
  455.                 oldnum$ = num$
  456.                 _PRINTSTRING (55, 30), "                          "
  457.                 num$ = ""
  458.                 GOTO nex2:
  459.             END IF
  460.             IF t = 1 THEN
  461.                 num = VAL(oldnum$) * VAL(num$)
  462.                 t = 0
  463.             END IF
  464.             GOSUB number2:
  465.             nex2:
  466.             buttonx = 275: buttony = 185
  467.             GOSUB press:
  468.         END IF
  469.  
  470.         'Divide
  471.         IF mousex > 275 AND mousex < 350 AND mousey > 130 AND mousey < 185 THEN
  472.             divide:
  473.             IF d = 0 THEN
  474.                 d = 1: a = 0: s = 0: t = 0
  475.                 oldnum$ = num$
  476.                 _PRINTSTRING (55, 30), "                          "
  477.                 num$ = ""
  478.                 GOTO nex1:
  479.             END IF
  480.             IF d = 1 AND num$ <> "" THEN
  481.                 num = VAL(oldnum$) / VAL(num$)
  482.                 d = 0
  483.             END IF
  484.             GOSUB number2:
  485.             nex1:
  486.             buttonx = 275: buttony = 130
  487.             GOSUB press:
  488.         END IF
  489.     END IF
  490. 'For Number Buttons.
  491. number:
  492. num = VAL(num$)
  493.  
  494. 'For Math
  495. number2:
  496. COLOR _RGB32(0, 0, 0), _RGB32(0, 0, 0)
  497. _PRINTSTRING (55, 30), "                          "
  498. num$ = STR$(num)
  499. COLOR _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  500. _PRINTSTRING (55, 30), num$
  501.  
  502.  
  503. 'Pressing Each Button
  504. press:
  505. c = 110
  506. FOR bb = 0 TO 10
  507.     c = c - 10
  508.     LINE (buttonx + bb, buttony + bb)-(buttonx + 75 - bb, buttony + 55 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
  509. NEXT bb
  510. _DELAY .25
  511. FOR bb = 0 TO 10
  512.     c = c + 10
  513.     LINE (buttonx + bb, buttony + bb)-(buttonx + 75 - bb, buttony + 55 - bb), _RGB32(100 + c, 100 + c, 100 + c), B
  514. NEXT bb
  515.  
  516. 'Pressing the Green C Button.
  517. zero:
  518. c = 110
  519. FOR bb = 0 TO 10
  520.     c = c - 10
  521.     LINE (buttonx + bb, buttony + bb)-(buttonx + 75 - bb, buttony + 55 - bb), _RGB32(50, 100 + c, 50), B
  522. NEXT bb
  523. _DELAY .25
  524. FOR bb = 0 TO 10
  525.     c = c + 10
  526.     LINE (buttonx + bb, buttony + bb)-(buttonx + 75 - bb, buttony + 55 - bb), _RGB32(50, 100 + c, 50), B
  527. NEXT bb
  528.  
  529. help:
  530. _TITLE "Calculator Help"
  531. PRINT "Esc = Keyboard Help"
  532. PRINT "CTRL+C = Copies Output To Clipboard"
  533. PRINT "Left Mouse Click Output Copies To Clipboard."
  534. PRINT "Backspace = Deletes Output"
  535. PRINT "Letters can be upper or lower-case."
  536. PRINT "P or N = Positve and Negative Switch."
  537. PRINT "F = 1 / x"
  538. PRINT "H = x / 2"
  539. PRINT "E = EXP"
  540. PRINT "R or D = Radian and Degree Switch."
  541. PRINT "U = X ^ 2"
  542. PRINT "L = Logarithm"
  543. PRINT "I = Pi"
  544. PRINT "Q = Square Root"
  545. PRINT "s = Sine"
  546. PRINT "c = Cosine"
  547. PRINT "t = Tangent"
  548. PRINT "Below can be either Number Pad or the others."
  549. PRINT "1-9 = Number Keys"
  550. PRINT ". = Decimal"
  551. PRINT "= = Equals"
  552. PRINT "+ = Add"
  553. PRINT "- = Subtract"
  554. PRINT "* or X = Multiply"
  555. PRINT "/ = Divide"
  556. PRINT "Press Esc to go back to calculator."
  557. _TITLE "Calculator - Esc for help."
  558. GOTO begin:
  559.  
  560.  
  561. 'This Function is from Dav which makes the icon picture. It uses code at the start of this program.
  562. FUNCTION BASIMAGE1& 'calculatio icon data
  563.     v& = _NEWIMAGE(54, 48, 32)
  564.     DIM m AS _MEM: m = _MEMIMAGE(v&)
  565.     A$ = ""
  566.     A$ = A$ + "haIkJ^eBK\557GZJOl02m5YDX5J1A:YC0aGE##Oc?0RUD5A:HDOA=N=2N96`"
  567.     A$ = A$ + ";87A#=X?hm4S6=N3_[XV4CRgn4]>co5=SJdI?IR9R7K2lSmNFke\bj?c<[I]"
  568.     A$ = A$ + "3QXknHbT9:]dB;Y`kblMd7Tn#B3cF=CZmYb:[Tb<c<Y<b83Ua8c5QJnTNjY["
  569.     A$ = A$ + "X[go?_W<f^AbX=I\7O8IGRiA[eSAbZ7[ZZ[nj[?Z`2;DgD#15lTf;ZXRXlc?"
  570.     A$ = A$ + "okdUEiL`Q<>Ua]nAb]4c3\?_<S8[;_Z[[4mmQIWMfDNiUg3eeTb\[<1T9\n#"
  571.     A$ = A$ + ":\4SR=obhEVAOUX[moCNM[n#j6965KQTImDj:U^BY;mZ[O4j7D>[T3Ukfin\"
  572.     A$ = A$ + "eEomg?EB9U`DLa5[#dfRLlm]7mi0PVb:[\R;MmY>o4mUom;D>NbQnn1OoEee"
  573.     A$ = A$ + "[kSNee7]lAjKcl=b#03T1o6NcX[Lg:Gjc3mIj[CmEbP_g>jjeLM3Ee5jg0m:"
  574.     A$ = A$ + "4DO85DRAaV?IFkER^V#V5TaUnAbU4c3\?WaGln3OT^Jc8gk=gCOLPT=9V7]F"
  575.     A$ = A$ + "GRkWOjYWVZYVJ8cV=cSA07;2]l1[okJn=mc6o9IbR9jG=o[4:8V>Lj#EM]jZ"
  576.     A$ = A$ + "[B3>hPdHS=6chS?^bX84i3FKTA6Q\Je:3V7;a<F1a2ilJ[]VZj2[=jXSB;_l"
  577.     A$ = A$ + "bdNk]7M`17#k_onlX8Dc74S=fH3Jb9WDAGH>\59n?7#<#^RLf[G_JZ[eGOM:"
  578.     A$ = A$ + "H`PdeGO=c=gLS#DcW#Q2aJ>JM1KQ37V^mfKe5ARKTSAlA^VBGYdE:Mmg]^6H"
  579.     A$ = A$ + "P1X012lRZ;\o\>k\CZWNjQjZ[^hl\nj[WkCIXQ6RlkgOL[[;_lBnk7onLK^i"
  580.     A$ = A$ + "VD]eF;eJ[]B]dB;D5ED1O^9;MeNk]CmfK_T=KfX>jX3Zk^kVeDS=f8EGMeAW"
  581.     A$ = A$ + "NjY?k[GUFJY\N#O:8VEGMeDIUE6IaRUTV^P]S>j8>o?olcY3?l#nN6TWhh[^"
  582.     A$ = A$ + "jZW]^>iTChc3SPc>k<VkO_`o7On:IFgh]FOD_EkkMa5GTOn<JJ^iV5RFnPeA"
  583.     A$ = A$ + "]5#\4?m2RYCW>EEG[\b:LmKD_;2AZo92]l1_GX]fJS1ce:Nj5TcNlhAhcGhn"
  584.     A$ = A$ + "TiVK>Fo^LiBID4RlIQ5FPVHR9D^?4cQ=]RI\2bETcaBM3<jcW?jR;^P1e65Q"
  585.     A$ = A$ + "JnPJck^k^?Z^1\Qed:^J1ba8ilOceiQ_hLR>>RnnN:k8gCTj:JBY[Dj2m5^m"
  586.     A$ = A$ + "fKcnnFBGc>k\DiUG>_?UMfIWTR^>nhSiL1m<mBY;DSMZYVRZZZZX]fJ[4^^P"
  587.     A$ = A$ + "?XoXIVIVGd[GH_3hMR3?l`lnCBdjJniWWO?WXW_CEgh^gMSn1`i1#>82el1e"
  588.     A$ = A$ + "FD[O3\VFaE;#>RL=Fd5je2g3\dB;A^MkFID4Rl1m>j`Q35MQi`VFa<F1iZFm"
  589.     A$ = A$ + "7RNRAoff]KG1lOVjn7oDXU?XWKlKS0`L]RWN1i\Xnian_JZYVDf[D4P=AXU?"
  590.     A$ = A$ + "Hm6JX1VH9Na3A_o[o3Ph%%L2"
  591.     btemp$ = ""
  592.     FOR i& = 1 TO LEN(A$) STEP 4: B$ = MID$(A$, i&, 4)
  593.         IF INSTR(1, B$, "%") THEN
  594.             FOR C% = 1 TO LEN(B$): F$ = MID$(B$, C%, 1)
  595.                 IF F$ <> "%" THEN C$ = C$ + F$
  596.             NEXT: B$ = C$: END IF: FOR j = 1 TO LEN(B$)
  597.             IF MID$(B$, j, 1) = "#" THEN
  598.         MID$(B$, j) = "@": END IF: NEXT
  599.         FOR t% = LEN(B$) TO 1 STEP -1
  600.             B& = B& * 64 + ASC(MID$(B$, t%)) - 48
  601.             NEXT: X$ = "": FOR t% = 1 TO LEN(B$) - 1
  602.             X$ = X$ + CHR$(B& AND 255): B& = B& \ 256
  603.     NEXT: btemp$ = btemp$ + X$: NEXT
  604.     btemp$ = _INFLATE$(btemp$)
  605.     _MEMPUT m, m.OFFSET, btemp$: _MEMFREE m
  606.     BASIMAGE1& = _COPYIMAGE(v&): _FREEIMAGE v&
  607.  
« Last Edit: July 30, 2020, 03:22:03 pm by SierraKen »