passing long string variable

Hi Folks-

I’m looking for an elegant way to deal with passing long strings of variables to Illustrator. Say I’m trying to do multiple find and replaces. I have had no problem passing numerical values, but if I try to pass a whole phrase, it balks.

works


set theVar to 2.0
tell application "Adobe Illustrator"
	set selection to (every path item of document 1 whose properties contains {stroke width:theVar})
end tell

no worky


set theVar to "closed:false"
tell application "Adobe Illustrator"
	set selection to (every path item of document 1 whose properties contains {theVar})
end tell

While the second example is simplistic, the idea is to create longer strings, which would then be passed to Illustrator.

Thanks,

Ralph

Hi,

you cannot pass properties as literal string variables at run time,
because all application terminology must be first compiled

I don’t really understand what your after. But if you want to get elements of which a property contains a specified value, you can do it (in most cases) with whose blabla contains/is/is not/does not contain blabla. So maybe this will work for you:

set theVar to 2.0
tell application "Adobe Illustrator"
   set selection to (every path item of document 1 whose stroke width is theVar)
end tell

Hope it works,
ief2

Ralph wants something like this


set theVar1 to {"closed:false"}
set theVar2 to {"closed:false", "stroke width:2.0"}
tell application "Adobe Illustrator"
	set selection to (every path item of document 1 whose properties contains theVar1)
	-- do something
	set selection to (every path item of document 1 whose properties contains theVar2)
	-- do something
end tell

I’m quite sure that this doesn’t work either


set theNum to 2.0
tell application "Adobe Illustrator"
	set theVar1 to {closed:false}
	set theVar2 to {closed:false, stroke width:theNum}
	set selection to (every path item of document 1 whose properties contains theVar1)
	-- do something
	set selection to (every path item of document 1 whose properties contains theVar2)
	-- do something
end tell

And yet, Stefan, your second version works.


set theNum to 2.0
tell application "Adobe Illustrator"
	set theVar1 to {closed:false}
	set theVar2 to {closed:false, stroke width:theNum}
	set selection to (every path item of document 1 whose properties contains theVar1)
	-- do something
	set selection to (every path item of document 1 whose properties contains theVar2)
	-- do something
end tell

yields:

set selection to every path item of document 1 whose properties contains {closed:false}
	set selection to every path item of document 1 whose properties contains {closed:false, stroke width:2.0}

this suggests that Applescript is compiling the individual sections, perhaps in the same manner as references?

Thanks! :smiley:

-Ralph