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: Tue, 01 Aug 2006 12:01:09 +0200
- Thread-topic: Add prices with taxes in quark
Thanks kai and adam for your great input.
It is a big help.... Both options given will work in quark.
Best regards,jan
> From: kai <email@hidden>
> Reply-To: applescript-users <email@hidden>
> Date: Mon, 31 Jul 2006 21:43:45 +0100
> To: applescript-users <email@hidden>
> Subject: Re: Add prices with taxes in quark
>
>
> On 31 Jul 2006, at 10:44, Jan Bultereys wrote:
>
>> 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.
>
> Hi Jan. In general terms, this type of operation might be performed
> in three stages:
>
> [1] get the required text from the application
>
> [2] modify the extracted text as required in AppleScript
>
> [3] replace the original text in the application with the modified
> version
>
>
> Like Adam, I'm afraid I don't use Quark - so I can't be specific
> about getting and setting its selection property. If you're unsure
> about that part, then perhaps a Quark user could help out?
>
> As for the text modification in AppleScript, this would typically be
> carried out using a handler. To give you a better idea of how this
> might work, I'll have to use another application. Since many Cocoa
> apps don't yet seem to feature a (text) selection property, I'll
> demonstrate the principle using a decent text editor, such as Tex-
> Edit Plus, instead:
>
> -------------
>
> 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
>
> tell application "Tex-Edit Plus"
> set original_text to selection
> set modified_text to my (insert_tax into original_text at 21 to 1)
> (* at: tax rate (%), to: max decimal places *)
> set selection to modified_text
> end tell
>
> -------------
>
> Each application may require a slightly different approach or syntax.
> For example, to get the above to work with TextWrangler (and possibly
> BBEdit), the first line of the application tell statement would need
> a minor modification:
>
> -------------
>
> tell application "TextWrangler"
> set original_text to contents of selection
> set modified_text to my (insert_tax into original_text at 21 to 1)
> set selection to modified_text
> end tell
>
> -------------
>
> The approach in Quark will almost certainly differ again - although
> you may be able to figure it out with a little experimentation. If
> not, and nobody else jumps in with a Quark-specific suggestion in the
> meantime, be sure to ask again...
>
> :-)
>
> ---
> 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