-
All replies
-
Helpful answers
-
Jun 10, 2016 5:48 AM in response to Kevlesserby VikingOSX,Launch Script Editor (Launchpad : Other : Script Editor). Copy and paste the following AppleScript into it. Click the hammer icon (compile), and then the ▸ button to run it. Save your script as File format: Text, and then option+File menu : Save As to any of Format (script, script bundle, or Application) to your Desktop. A double-click will run it.
try
display dialog "Total sheet height" default answer ""
set A to text returned of result
display dialog "Total job height" default answer ""
set B to text returned of result
on error errmsg number errnbr
my error_handler(errnbr, errmsg)
return
end try
ignoring numeric strings
set answer to (A - B) / 2
end ignoring
display dialog "Your result is " & answer as text
return
on error_handler(nbr, msg)
display alert "[ " & nbr & " ] " & msg as critical giving up after 10
return
end error_handler
tr
-
Jun 10, 2016 8:26 AM in response to Kevlesserby SGIII,A succinct approach if you don't need error handling is:
set sh to text returned of (display dialog "Total sheet height: " default answer "")
set jh to text returned of (display dialog "Total job height: " default answer "")
set theResult to (sh - jh) / 2
display dialog "Your Result is: " & theResult buttons "OK"
Or with some error handling:
set sh to text returned of (display dialog "Total sheet height: " default answer "")
set jh to text returned of (display dialog "Total job height: " default answer "")
try
if sh * jh > 0 then
set theResult to (sh - jh) / 2
display dialog "Your Result is: " & theResult buttons "OK"
else
error
end if
on error
display dialog "Enter values > 0" buttons "OK"
end try
SG