I have a series of Applescripts that run in Photoshop CS5 that set the contents of text objects with variable data read from a plist. In addition to editing the normal text objects in text layers I need to be able to edit the contents of a text object in a smart object. To accomplish this I believe I need to use the listener and use javascript. I plan to run the Javascript from within the Applescript using do javascript command. My dilemna is how do I pass the text variable from the Applescript to the Javascript?
As you can see I am a novice scripter!
This first script works fine as the variable myVar is inside the Javascript.
tell application "Adobe Photoshop CS5"
activate
set theJavaCode to "{
myVar = 'Get Shorty'
var originalUnit = preferences.rulerUnits
preferences.rulerUnits = Units.MM
var docRef = app.documents.add( 100, 150 )
var artLayerRef = docRef.artLayers.add()
artLayerRef.kind = LayerKind.TEXT
var textItemRef = artLayerRef.textItem
textItemRef.contents = myVar
docRef = null
artLayerRef = null
textItemRef = null
app.preferences.rulerUnits = originalUnit
}"
do javascript theJavaCode
end tell
This second script does not work as I cannot figure out how to pass the text data from the Applescript to the variable contained inside the Javascript.
tell application "Adobe Photoshop CS5"
activate
set myVar to "Get Shorty"
set theJavaCode to "{
var originalUnit = preferences.rulerUnits
preferences.rulerUnits = Units.MM
var docRef = app.documents.add( 100, 150 )
var artLayerRef = docRef.artLayers.add()
artLayerRef.kind = LayerKind.TEXT
var textItemRef = artLayerRef.textItem
textItemRef.contents = myVar
docRef = null
artLayerRef = null
textItemRef = null
app.preferences.rulerUnits = originalUnit
}"
do javascript theJavaCode
end tell