function OnInit(initData) { initData.name = "dlgtest1"; initData.vars("name") = initData.name; initData.desc = "Opus v12 Dialog Testbed"; initData.version = "1.0 (October 16th, 2019)"; initData.vars("version") = initData.version; initData.default_enable = true; initData.min_version = "12"; var cmd = initData.AddCommand(); cmd.name = initData.name; cmd.method = "do_main"; cmd.desc = initData.desc; cmd.label = initData.name; cmd.template = "s1/s"; // Switch available for use at run time // Define defaults for things the user can configure via Preferences --> Scripts initData.config_desc = DOpus.create.map(); initData.config.dbg = true; initData.config_desc("dbg") = 'If set to TRUE, trace information is written to "Other" log.'; initData.config.clearlog = true; initData.config_desc("clearlog") = 'If set to TRUE, clear "Other" log if dbg = TRUE.'; } function do_main(ScriptCommandData) { // Process switches that can be set in Preferences // and define and initialise a few variables var dbg = Script.config.dbg; var clearlog = Script.config.clearlog; if ((dbg) && (clearlog)) DOpus.clearoutput(); var str = Script.vars("name") + " version " + Script.vars("version"); if (dbg) DOpus.output(str+" starting.."); var loop_counter = 0; var item_index = 0; var msg_obj; var s1 = ScriptCommandData.func.args.s1 // Will be TRUE if switch s1 providen on command line var cmd = (s1) ? ScriptCommandData.func.command : DOpus.create.command; // Prepare a detached dialog for use var src = DOpus.listers.lastactive.activetab; var dlg = DOpus.dlg; dlg.window = src; dlg.template = "dlg1"; // See dialog details below under SCRIPT RESOURCES dlg.title = "Just testing"; // Title must be set BEFORE the dialog is created dlg.create; // Create, but don't yet display, a detached dialog // Perform any pre-display dialog initialisation here dlg.control("Text1").label = "Tab = " + src.path.filepart; dlg.control("Text2").label = "# of items selected = " + src.selected.count; dlg.show; // Display the detached dialog // Loop until the dialog is closed by the user do { msg_obj = dlg.getmsg(); if (msg_obj==false) break; // User has terminated the dialog if (msg_obj.event=="focus") continue; // Ignore focus changes if (dbg) { loop_counter++; str = loop_counter + ": " + msg_obj.event + " " + msg_obj.control; DOpus.output(str); } if (msg_obj.control=="btnQuit") break; else if (msg_obj.control=="btnProcess") { src = DOpus.listers.lastactive.activetab; var n = src.selected.count; str = "Tab = " + src.path.filepart dlg.control("Text1").label = str; if (dbg) DOpus.output(str); str = "# of items selected = " + n; dlg.control("Text2").label = str; if (dbg) DOpus.output(str); cmd.setsourcetab(src); if (n>0) cmd.runcommand("Help About"); if (n>0) cmd.runcommand("Delete"); } } while (msg_obj); if (dbg) DOpus.output("dlg.result = " + dlg.result); } ==SCRIPT RESOURCES