Re: QuarkXPress 4.11 script breaks in 6.5 - Why? (AND: Can anyone explain this?)
Re: QuarkXPress 4.11 script breaks in 6.5 - Why? (AND: Can anyone explain this?)
- Subject: Re: QuarkXPress 4.11 script breaks in 6.5 - Why? (AND: Can anyone explain this?)
- From: Dan Feather <email@hidden>
- Date: Tue, 25 Apr 2006 07:52:44 -0500
- Thread-topic: QuarkXPress 4.11 script breaks in 6.5 - Why? (AND: Can anyone explain this?)
Peter,
I must say, this is MOST interesting! . . . At first, I almost passed your
post by, since I was SURE my variable had already become a string. Here's my
test script:
------------
set varSearch to text returned of (display dialog "" default answer "WWW")
set varReplace to text returned of (display dialog "" default answer "ASD")
tell application "QuarkXPress"
set varSearch to (varSearch & "-") as string
set varReplace to (varReplace & "-") as string
log {class of varReplace, class of varSearch}
tell document 1
set every text of every story where it is varSearch to varReplace
end tell
end tell
--------------
The script log showed that varReplace and varSearch were of class "string"
However, after I tried passing the variables through your subroutine, it
worked!
How can it be that the script log's "proof" that my variables were string
could not be relied on?
Can anyone explain this, and offer suggestions as to how to determine when
logged can and can't be relied on?
Many thanks!
- Dan
on 4/25/06 5:14 AM, Peter Waibel at wrote:
> Hi Dan,
>
> some days ago I found a very usefull subroutine "AsText()" in this forum
> and saved it to my disk.
> Unfortunately I didn't find the post in the forum again.
> There has been a lot of usefull informations about coercing text in
> that thread.
>
> I think the problem is, that XPress needs class string as arguments
> but your varSearch and varReplace is probably international text!
>
> If you do this in AS:
>
> set varSearch to "WWW-" as international text
> --set varSearch to "WWW-" as styled text
> set varSearch to varSearch as string
> return class of varSearch
> --> string
>
> But the class is still "international text"
> (for AS "international text" must be somthing like a subclass)
>
> The subroutine "AsText()" should solve your problem.
> This code worked for me:
>
>
> set varSearch to "WWW-" as international text
> set varReplace to "ASD-" as styled text
>
> set varSearch to AsText(varSearch)
> set varReplace to AsText(varReplace)
>
> tell application "QuarkXPress Passport"
> tell document 1
> set every text of every story where it is varSearch to varReplace
> end tell
> end tell
>
> on AsText(str)
> --coerce Unicode or other text to styled string to plain text
> try
> return (((str as string) as record)'s «class ktxt»)
> end try
> return str as string -- if plain text to begin with, or if real
> Unicode, change to "?"
> end AsText
>
>
> Peter
>
>
>
> Am 24.04.2006 um 20:46 schrieb Dan Feather:
>
>> Why won't this script line work w/ QuarkXPress 6.5? It worked fine
>> w/ 4.11.
>>
>> -- script snip:
>> tell application "QuarkXPress"
>> tell document 1
>> set every text of every story where it is varSearch to varReplace
>> end tell
>> end tell
>> --
>>
>> The error is -10006
>>
>> If I replace the variable names with actual strings, it works fine.
>> Thinking
>> the problem had something to do with that, I tried the following:
>>
>> set {varSearch, varReplace} to {"WWW-", "ASD-"}
>> set every text of every story where it is varSearch to varReplace
>>
>> . . . and it worked fine.
>>
>> I compared (using "log class of..") that command with mine and found
>> variables were all of class string. (Mine are set by display
>> dialog, so I
>> use a second line to change Unicode text to string.)
>>
>> Anyway, it's taking me to the edge!
>>
>> Many thanks,
>>
>> Dan
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Applescript-users mailing list (Applescript-
>> email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40opix.de
>>
>> This email sent to email@hidden
>
>
> Grüße aus Berlin
>
> Peter Waibel
>
>
> --------------------------------
> Opix AG
> Peter Waiibel
> Am Borsigturm 46
> 13357 Berlin
>
> Fon: +49 30 4303 4421
> Fax: +49 30 4303 4409
>
> email@hidden
>
> email@hidden
> email@hidden
> http://www.opix.de
> --------------------------------
>
>
>
>
_______________________________________________
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