Created
December 29, 2011 00:46
-
-
Save eccegordo/1530777 to your computer and use it in GitHub Desktop.
Indesign Script Isolated doAction function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup the variables | |
var theDocument = app.activeDocument; | |
var myInputs = {}; | |
myInputs.inputDocumentName = "Foo Document Name"; | |
myInputs.inputDocumentType = "Bar Doc Type"; | |
var myOptions = {}; | |
// Call the doAction function | |
doAction(theDocument, myInputs, myOptions); | |
// The function with the get and set behavior for textVariables | |
function doAction(docRef, inputs, options) { | |
alert("doAction " + docRef.name + " \n INPUTS: \n" + inputs.reflect.properties + "\n\n OPTIONS: \n" + options.reflect.properties); | |
// Get the current contents | |
var fooContents = app.activeDocument.textVariables.item ('Foo').variableOptions.contents; | |
var barContents = app.activeDocument.textVariables.item ('Bar').variableOptions.contents; | |
alert("GET textVariable contents \n Foo: \n" + fooContents + "\n\n Bar: \n" + barContents); | |
// Set/Update the contents | |
// Why does this not seem to work? | |
alert("SET textVariable contents \n Foo: \n" + inputs.inputDocumentName + "\n\n Bar: \n" + inputs.inputDocumentType); | |
app.activeDocument.textVariables.item ('Foo').variableOptions.contents = inputs.inputDocumentName; | |
app.activeDocument.textVariables.item ('Bar').variableOptions.contents = inputs.inputDocumentType; | |
// Script does not seem to reach this point. Why? | |
alert("END of doAction"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment