Hello,
I'm having a bit of an issue with some InDesign scripting i'm working on, and wonder if anyone else has had the same issue.
I have a script that uses app.dialog to prompt for user information. It then takes the result of that dialog, and uses it in the script. Pretty standard so far, and if i run this from the scripts panel, or from ESTK, it works fine. If I set it up as a Script Menu Action, when I run the script via the menu, it executes, then crashes InDesign.
I have tried this with multiple dialog's, and each time a dialog is called from a SMA, InDesign crashes. The following code is fairly pointless, but will cause InDesign to crash when the SMA is run.
/******************************************************/////failTest.jsx//Test script will cause InDesign to crash when the SMA is invoked//Daniel Cole//Wed Jun 09 2010 13:26:47 GMT-0400///******************************************************/
#targetengine "session" //set up the SMA and eventListener
var saTest = app.scriptMenuActions.add("Test SMA");
var elTest = saTest.eventListeners.add("onInvoke", function() { alert(testFunc()); }); //Check for the menu, and create it if it doesn't existtry{ var menuTest = app.menus.item("$ID/Main").submenus.item("Test"); menuTest.title;}catch (e){ var menuTest = app.menus.item("$ID/Main").submenus.add("Test");}
menuTest.menuItems.add(saTest) //test function//creates a dialog box with a text edit box//returns the content of the text edit box
function testFunc(){ testDialog = app.dialogs.add({name:"Enter Text:", canCancel:true}); with(testDialog){ with(dialogColumns.add()){ var getTextField = textEditboxes.add({editContents: "Test Text", minWidth:250}); } } testResult = testDialog.show() if(testResult == true){ var testText = getTextField.editContents; testDialog.destroy(); return testText; } else{ return"No Text Entered"; myFileDialog.destroy(); }}
I've tried this on CS4 and CS5, on multiple installs, and it crashes every time. Can anyone else replicate this? Is this a known issue? Is there any way to work around it?
thanks,
Daniel Cole
Electronic Prepress and Automation Specialist
Disc Makers