Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add prices with taxes in quark




On 27 Jul 2006, at 18:05, Adam Bell wrote:

I don't have Quark, but assuming you can 'grab' a line of the text, that the price could have one place after the decimal point, and that you want only one place after the decimal point of the price with tax added, this script will do it:

set aPriceLine to "Paper 11.1 22.2 33.3" as Unicode text
set w to words of aPriceLine
repeat with k from 2 to count w
tell item k of w to set T to it & space & "(" & ((12.1 * it) as integer) / 10 & ")"
set item k of w to T
end repeat
w

This variation should preserve any characters between words, as well as any text encoding. (It should also skip any non-numeric words.)


-------------

to insert_tax into s at r to p
set {p, r, l, d} to {10 ^ p, r / 100, s's words, text item delimiters}
repeat until (count l) is 0
set {i, l} to l's {beginning, rest}
if i is not in l then try
set text item delimiters to i
set t to s's text items
set text item delimiters to i & " (" & ((i + i * r) * p as integer) / p & ")"
tell t to set s to beginning & ({""} & rest)
end try
end repeat
set text item delimiters to d
s
end insert_tax


set price_string to "Paper 11.1 22.2 33.3" (* values must be positive *)
set tax_rate to 21 (* % *)
set dec_places to 1 (* maximum - i.e. won't pad beyond 1 place with trailing zeros *)


insert_tax into price_string at tax_rate to dec_places

--> "Paper      11.1 (13.4)       22.2 (26.9)        33.3 (40.3)"

-------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Add prices with taxes in quark (From: Jan Bultereys <email@hidden>)
 >Re: Add prices with taxes in quark (From: Adam Bell <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.