Re: Add prices with taxes in quark
Re: Add prices with taxes in quark
- Subject: Re: Add prices with taxes in quark
- From: Jan Bultereys <email@hidden>
- Date: Mon, 31 Jul 2006 11:44:47 +0200
- Thread-topic: Add prices with taxes in quark
Hi Kai, how would you implement this in Quark?
example: select the line in quark where prices are without taxes
Run the script
The selected line goes back to quark with prices and prices taxes incl.
Already many thanks for your help
jan
> From: kai <email@hidden>
> Reply-To: applescript-users <email@hidden>
> Date: Sun, 30 Jul 2006 23:59:19 +0100
> To: applescript-users <email@hidden>
> Subject: 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:
> edepot.com
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden