//v0.3.8 - 2024-05-17 //- reorder version history //v0.3.7 - 2022-01-19 //- prevent exception if run via DOpus.NewCommand.RunCommand() or CLI tool (..sourcetab.lister not set for some reason) //v0.3.6 - 2017-06-08 //- added logprefix "Say" //v0.3.5 - 2016-01 //- order of variable resolving changed from local to global scope //v0.3.4 - 2015-10 //- data.func.command.deselect = false; //- bug fix resolving $dst-scoped variables //v0.3.2 - 2015-01 //- command-template added to make button editors variable dropdown-menu available //- mechanics to edit the commands name disabled //v0.3.1 //- min version added //- prepared for automatic updates/script wizard //v0.1 - 2014-09 //- initial version /////////////////////////////////////////////////////////////////////////////// //var COMMANDNAME = "Say"; /////////////////////////////////////////////////////////////////////////////// function OnInit(data){ var url = "http://resource.dopus.com/viewtopic.php?f=35&t=23117"; var uid = "F578E644-27F5-4A00-96D3-9DAF337444C2"; data.name = "Command.Generic: Say"; data.desc = "Output text to output/script console."; data.copyright = "tbone"; data.version = "0.3.8"; data.min_version = "11"; data.default_enable = true; if (DOpus.Version.AtLeast("11.8.2")) data.log_prefix = "Say "; var cmd = data.AddCommand(); cmd.name = "Say"; cmd.label = "Say" //name = COMMANDNAME; cmd.method = "Command_Say"; //cmd.method = "Command_"+COMMANDNAME; cmd.desc = data.desc; cmd.template = "Dummy/S"; } /////////////////////////////////////////////////////////////////////////////// var COMMAND_ABORTED = true; var COMMAND_SUCCEEDED = false; /////////////////////////////////////////////////////////////////////////////// //this["Command_"+COMMANDNAME] = function (data) { function Command_Say(data){ data.func.command.deselect = false; //data.func.command.ClearFiles(); var text = data.cmdline.substring("Say".length+1); //var text = data.cmdline.substring(COMMANDNAME.length+1); var match; text = ReplaceVars(text, /\{\$src\:.*?\}/gi, data.func.sourcetab.vars, "$src:"); if (data.func.desttab) text = ReplaceVars(text, /\{\$dst\:.*?\}/gi, data.func.desttab.vars, "$dst:"); //make it work in DO's CLI/scripting test window/tool (.lister seems not to be set). //or it is "DOpus.NewCommand.RunCommand(..) which does not set .lister on sourcetab if (data.func.sourcetab.lister) text = ReplaceVars(text, /\{\$lst\:.*?\}/gi, data.func.sourcetab.lister.vars, "$lst:"); text = ReplaceVars(text, /\{\$.*?\}/gi, DOpus.Vars, "$"); text = ReplaceVars(text, /\{\$glob\:.*?\}/gi, DOpus.Vars, "$glob:"); text = ReplaceColors(text); DOpus.Output(text); return COMMAND_SUCCEEDED; } /////////////////////////////////////////////////////////////////////////////// function ReplaceVars( text, re, vars, id ) { text = text.replace(re, function(strMatch,index,strFull){ var varName = strMatch.substring(1+id.length,strMatch.length-1); var varValue = strMatch; if (vars.Exists(varName)) varValue = vars.Get(varName); return varValue; } ) return text; } /////////////////////////////////////////////////////////////////////////////// function ReplaceColors(text) { var fg = '000000'; var bg = 'ffffff'; var re = /\<.*?\>/gi; if (text.indexOf("")!=-1) text = text.replace(//gi,'')+'1 && parts[1]!="" && cols[parts[1]]==undefined)) return strMatch; var fgCol = (parts[0]!=""?cols[parts[0]]:fg); var bgCol = (parts.length==2 && parts[1]!=""?cols[parts[1]]:bg); return result = ""; } ) if (textC!=text) textC+=""; return textC; } /////////////////////////////////////////////////////////////////////////////// function OnAboutScript(data){ //v0.1 var cmd = DOpus.Create.Command(); if (!cmd.Commandlist('s').exists("ScriptWizard")){ if (DOpus.Dlg.Request("The 'ScriptWizard' add-in has not been found.\n\n"+ "Install 'ScriptWizard' from [resource.dopus.com].\nThe add-in enables this dialog and also offers "+ "easy updating of scripts and many more.","Yes, take me there!|Cancel", "No About.. ", data.window)) cmd.RunCommand('http://resource.dopus.com/viewtopic.php?f=35&t=23179');} else cmd.RunCommand('ScriptWizard ABOUT WIN='+data.window+' FILE="'+Script.File+'"'); } //MD5 = "21e777ba8d323942e876c842d2cbec7c"; DATE = "2024.05.17 - 19:05:29"