Advertisement
TheSuperProGamer

AppleScript Calculator

Jun 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set r to return as text
  2. display dialog "Choose an operation" buttons {"Add", "Subtract", "Other"} with title "Calculator"
  3. set opr to button returned of the result
  4. -- You pressed add
  5. if opr is "Add" then
  6.     display dialog "Enter your first number in the equation" default answer "" with title "First Number"
  7.     set FirstNumber to text returned of the result
  8.     display dialog "Your curent equation is " & FirstNumber & "+?" & r & "Enter your second number" default answer "" with title "Second Number"
  9.     set SecondNumber to text returned of the result
  10.     display dialog "Your equation is " & FirstNumber & "+" & SecondNumber & r & r & "Answer: " & FirstNumber + SecondNumber buttons {"OK"}
  11.     -- you picked subtract
  12. else if opr is "Subtract" then
  13.     display dialog "Enter your fisrt number in the equation" default answer "" with title "First Number"
  14.     set FirstNumber to text returned of the result
  15.     display dialog "Your curent equiation is" & FirstNumber & "-?" & r & "Enter your second number" default answer "" with title "Second Number"
  16.     set SecondNumber to text returned of the result
  17.     display dialog " your equation is" & FirstNumber & "-" & SecondNumber & r & r & "Answer: " & FirstNumber - SecondNumber buttons {"OK"}
  18. else
  19.     display dialog "Pick your operation" buttons {"Multiply", "Divide"}
  20.     set X to button returned of the result
  21.     -- You picked multiply
  22.     if X is "Multiply" then
  23.         display dialog "Enter your first number in the equation" default answer "" with title "First Number"
  24.         set FirstNumber to text returned of the result
  25.         display dialog "Your curent equation is" & FirstNumber & "*?" & r & "Enter your second number" default answer "" with title "Second Number"
  26.         set SecondNumber to text returned of the result
  27.         display dialog "Your equation is" & FirstNumber & "*" & SecondNumber & r & r & "Answer:" & FirstNumber * SecondNumber buttons {"OK"}
  28.     else
  29.         display dialog "Enter your first number in the equation" default answer "" with title "First Number"
  30.         set FirstNumber to text returned of the result
  31.         display dialog "Your curent equation is" & FirstNumber & "/?" & r & "Enter your second number" default answer "" with title "Second Number"
  32.         set SecondNumber to text returned of the result
  33.         display dialog "Your equation is" & FirstNumber & "/" & SecondNumber & r & r & "Answer:" & FirstNumber / SecondNumber buttons {"OK"}
  34.     end if
  35. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement