Script does not work when compiled

26 views
Skip to first unread message

Jeremy Dugan

unread,
Jan 9, 2013, 12:34:04 PM1/9/13
to multiad...@googlegroups.com

We have MultiAd Creator 7.0.4 and we are migrating the ads from this version. I have a script that iterates through the elements for duplication. 

It works if run from the script editor. If I save the script as an application it gives an error that the class of the element can not be made into a string. A screenshot of the error is attached as well.

The portion of the script that is failing:

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

tell application "MultiAd Creator Pro"

set everyprop to properties of every element of spread 1 of document 1

end tell

set countelements to count of items of everyprop

repeat with z from countelements to 1 by -1

tell application "MultiAd Creator Pro"

set thisprop to item z of everyprop

if (class of thisprop as string) is "path element" or (class of thisprop as string) is "starburst element" then

my pathhandler(thisprop)

else if (class of thisprop as string) is "oval element" then

my makeoval(thisprop)

else if (class of thisprop as string) is "rectangle element" then

my testrect(thisprop)

else if (class of thisprop as string) is "line element" then

my makeline(thisprop)

else if (class of thisprop as string) is "graphic element" then

my solographic(thisprop)

else if (class of thisprop as string) is "border element" then

my borderplace(thisprop)

else

my grouphandler(thisprop)

end if

end tell

end repeat

Based on the screenshot I thought perhaps I was trying to refer to the class improperly. I tried to use 'item 1' instead of the named value but it throws out the error that it can not be a string.
 
As I said, it works fine from the script editor. 

Running OS X 10.5.8 using Script Editor 2.2.1 if that matters to anyone. 
Picture 1.png

Steve Mills

unread,
Jan 9, 2013, 1:00:51 PM1/9/13
to multiad...@googlegroups.com
On Jan 9, 2013, at 11:34:04, Jeremy Dugan <jdu...@soundpublishing.com> wrote:

> We have MultiAd Creator 7.0.4 and we are migrating the ads from this version. I have a script that iterates through the elements for duplication.
>
> It works if run from the script editor. If I save the script as an application it gives an error that the class of the element can not be made into a string. A screenshot of the error is attached as well.
>
> The portion of the script that is failing:

First of all, why are you asking for every property if all you're using is the class property? Just ask for the class and compare it to the actual class name instead of converting to strings:

set aClass to class of every element of spread 1 of document 1

if aClass is oval element then
my makeoval()
else if etc...

Second, I'm not sure why you're asking for the properties of every element in the spread, but then you're looping over all the properties of every element. It would be more clear to iterating through the elements, asking each element for its class:

set num to number of elements of spread 1 of document 1

repeat with i from num to 1 by -1
set aClass to class of element i of spread 1 of document 1

if aClass is oval element then
blah
else if aClass is rectangle element then
etc
end if
end repeat

> Running OS X 10.5.8 using Script Editor 2.2.1 if that matters to anyone.

Wow. Ancient.

--
Steve Mills
Drummer, Mac geek


Reply all
Reply to author
Forward
Message has been deleted
0 new messages