I have used this script to help me track how much each CD i buy costs including tax. It works as is, however if I buy 3 CD’s, I have to run script 3x to calculate tax for each CD. I want to calculate in one shot based on how many CD’s I select in the property section. Not sure how to accomplish. Any help would be helpful. Thanks
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
--use myLib : script "Script_Run_Log_Library"
--set myName to name of (info for (path to me))
--myLib's scriptRunLog(myName)
--property TotalCDs : {"1", "2", "3", "4", "5"}
--choose from list TotalCDs with prompt "Number of CD's bought:"
--set TotalCD to result as number
--What I'm trying to do here is loop thru based on number selected so I can calculate
--tax for each CD instead of running this script multiple times. Not sure how to do this.
--If I run this as is, it works but if I buy 3 CD's, I have run script 3 times to get total cost for each CD
display dialog "Enter total Cost:" default answer "" with title "Total Cost"
set totalSale to text returned of result
display dialog "Enter pre tax total:" default answer "" with title "Pre Tax"
set beforeTaxTotal to text returned of result
set salesTax to totalSale - beforeTaxTotal
display dialog "Sales tax: " & salesTax with title "Sales Tax"
set taxratio to salesTax / beforeTaxTotal
display dialog "The Tax Rate Is: " & taxratio & " % " with title "Tax Rate"
display dialog "Enter cost of the CD:" default answer "" with title " Cost of CD"
set CDCost to text returned of result
set TaxCD to CDCost * taxratio
set ThisCD to TaxCD + CDCost
display dialog "Total Tax is: " & TaxCD with title "Total Tax"
display dialog "Total Cost is " & ThisCD with title " Total Cost"