🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15603

InDesign CS JavaScript: Script Control Dialog

#15603
From: Olav_Kvern
Date: Mon, 24 Nov 2003 23:42
50 lines
2350 bytes
Gang--

Here's a snippet that contains a JavaScript dialog box I frequently use to control execution of my scripts. When I create a script that might take a long time to run, I add this dialog to the script and place it at various "pain points" at which I might want to cancel execution of the script. This way, if I see somethign going wrong, I can cancel the script; if everything's going well, I can tell the script to continue without displaying the dialog box.



//ScriptControlDialog.js 
var myRunScript = false; 
var myBreakScript = false; 
var myDialog = app.dialogs.add({name:"Script Control", canCancel: false}); 
with(myDialog.dialogColumns.add()){ 
	with(dialogRows.add()){ 
		staticTexts.add({staticLabel:""}); 
	} 
	with(myActionButtons = radiobuttonGroups.add()){ 
		radiobuttonControls.add({staticLabel:"Continue Script", checkedState:true}); 
		radiobuttonControls.add({staticLabel:"Run Script (do not display this dialog again)"}); 
		radiobuttonControls.add({staticLabel:"Stop Script"}); 
	} 
} 
for(myCounter = 0; myCounter<10; myCounter++){ 
	if(myRunScript == false){ 
		myDialog.dialogColumns.item(0).dialogRows.item(0).staticTexts.item(0).staticLabel = "myCounter = " + myCounter; 
		myDialog.show(); 
		switch(myActionButtons.selectedButton){ 
			case 0: 
				//Do nothing. 
				break; 
			case 1: 
				//Run the rest of the script without displaying the dialog. 
				myRunScript = true; 
				break; 
			case 2: 
				//Skip the rest of the script. 
				myBreakScript = true; 
				break; 
		} 
	} 
	if(myBreakScript == true){ 
		break; 
	} 
} 
myDialog.destroy(); 
alert("Done!");



Thanks,

Ole
Technical Details
Message-ID: <2cce92df.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,9af433adf4d582ea,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-11-24 16:07:54 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: InDesign CS JavaScript: Script Control Dialog
Message-ID: <2cce92df.-1@webx.la2eafNXanI>
Date: Mon, 24 Nov 2003 15:42:05 -0800
Lines: 56
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit