Skip to content

Instantly share code, notes, and snippets.

@eccegordo
Created December 29, 2011 00:46
Show Gist options
  • Save eccegordo/1530777 to your computer and use it in GitHub Desktop.
Save eccegordo/1530777 to your computer and use it in GitHub Desktop.
Indesign Script Isolated doAction function
// 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