Re: INDESIGN: Coercing a String to a Constant
Re: INDESIGN: Coercing a String to a Constant
- Subject: Re: INDESIGN: Coercing a String to a Constant
- From: Rick Gordon <email@hidden>
- Date: Wed, 12 Oct 2011 01:58:19 -0700
FWIW, what I came up with was:
set vChanged to false
tell application "Adobe InDesign CS5"
set vApp to it
set vAppName to name
set vUnitsTextList to {"points", "picas", "inches", "inches decimal", "millimeters", "centimeters", "pixels"}
if exists document 1 then
--TARGET FRONT DOCUMENT PREFS
set vTarget to document 1
set vTargetText to return & "document " & name of document 1
else
--TARGET APP PREFS
set vTarget to vApp
set vTargetText to return & vAppName
end if
tell view preferences of vTarget
set vViewPrefs to it
if horizontal measurement units is equal to vertical measurement units then
--ASSUMES WE WANT TO CONTINUE WITH SYCHRONIZED H & V VALUES
set vMeasurementPropertyText to ""
try
set horizontal measurement units to my fSetMeasurement(vMeasurementPropertyText, vTargetText, vUnitsTextList, vAppName, horizontal measurement units of vViewPrefs)
set vChanged to true
set vertical measurement units to horizontal measurement units
set vChanged to true
end try
else
--H & V VALUES ARE ALREADY DIFFERENT SO WE'LL GO WITH THAT.
set vMeasurementPropertyText to "horizontal "
try
set horizontal measurement units to my fSetMeasurement(vMeasurementPropertyText, vTargetText, vUnitsTextList, vAppName, horizontal measurement units of vViewPrefs)
set vChanged to true
end try
set vMeasurementPropertyText to "vertical "
try
set vertical measurement units to my fSetMeasurement(vMeasurementPropertyText, vTargetText, vUnitsTextList, vAppName, vertical measurement units of vViewPrefs)
set vChanged to true
end try
end if
return {horizontal measurement units, vertical measurement units, vChanged}
end tell
end tell
on fSetMeasurement(aMeasurementPropertyText, aTargetText, aUnitsTextList, aAppName, aTarget)
try
tell me to set vResult to item 1 of (choose from list aUnitsTextList ¬
with prompt "Set " & aMeasurementPropertyText & ¬
"measurement units for " & aTargetText & " to:" default items {aTarget as text} ¬
without multiple selections allowed and empty selection allowed)
--COERCE TEXT RESULT TO ENUM
set vEnumResult to run script ("tell application \"" & aAppName & "\" to return " & vResult)
end try
return vEnumResult
end fSetMeasurement
------------------
On 10/12/11 at 12:28 AM -0700, Rick Gordon wrote in a message entitled
"Re: INDESIGN: Coercing a String to a Constant":
>Yup. A run script hack it is:
>
>...
>tell me to set vResult to item 1 of (choose from list vUnitsTextList ¬
> with prompt "Set measurement units for current document to:" ¬
> default items {pHorizontalUnits as text} ¬
> without multiple selections allowed and empty selection allowed)
>set vEnumResult to run script ("tell application \"" & vAppName & "\" to return " & vResult)
>...
>
>------------------
>
>On 10/12/11 at 4:50 PM +1100, Shane Stanley wrote in a message entitled
>"Re: INDESIGN: Coercing a String to a Constant":
>
>>On 12/10/2011, at 3:35 PM, Rick Gordon wrote:
>>
>>> There must be a better way, no?
>>
> >No. You can't create enumerations from strings, short of "run script" hacks.
--
___________________________________________________
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________
WWW: http://www.shelterpub.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden