How can I see what my opus scripts resolve to?

This has been an issue for me forever. How is it possible to see what commands are actually executed from an opus script?

Right now I'm trying to add a diff button that calls meld. It works using {filepath$} {filepathdest$} if I've got two files selected, but not if two folders are selected. I suspect that it's because folders end with \ and meld doesn't like that, but I can't check.

I'm using Opus 12.19.

I've just found a horrible way to do it.

I had to change the Function type to be an MS-DOS Batch function, set @leavedoswindowopen and then do an echo {filepath$} {destfilepath$}. Surely there's a better way?

Yes. Use a button with

@nodeselect
dopusrt /argsmsgbox {filepath$} {filepathdest$}

Use F5 for quick debugging while the command editor is open.

I often use the echo command and put the pause command at the end to keep the window open. (Fewer characters to type but not that different to what you're doing.)

lxp's dopusrt /argsmsgbox method is better sometimes as it supports unicode strings (DOS Batch can't) and gives the exact arguments (sometimes DOS Batch / echo processes special characters, although it's rare). Only problem is I can never remember the "argsmsgbox" part (despite being the one who chose the name!) and it's a pain to type every time.

This prompted me to write a little script that adds a command you can use to do things a bit easier, with less to remember. I haven't tested it much yet:

  • Out Command.js.txt (1.1 KB)
  • Download it and drag it to Preferences / Toolbars / Scripts.

Script code for reference (same as the download above):

function OnInit(initData)
{
	initData.name = "Out Command";
	initData.version = "1.0";
	initData.copyright = "(c) 2020 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/how-can-i-see-what-my-opus-scripts-resolve-to/34948/4";
	initData.desc = "An \"out\" command to help debug command-line arguments.";
	initData.default_enable = true;
	initData.min_version = "12.0";

	var cmd = initData.AddCommand();
	cmd.name = "Out";
	cmd.method = "OnCommandOut";
	cmd.desc = "Prints arguments into the Utility Panel window.";
	cmd.label = "Out";
	cmd.template = "C/R,O/R";
	cmd.hide = false;
	cmd.icon = "script";
}

function OnCommandOut(scriptCmdData)
{
	var args = scriptCmdData.func.args;

	var cmd = scriptCmdData.func.command;
	cmd.deselect = false;

	var str = "";

	if (args.got_arg.c)
	{
		DOpus.ClearOutput();
		str = args.c;
	}
	else if (args.got_arg.o)
	{
		str = args.o;
	}
	else
	{
		str = "Add C (clear and output) or O (output only) before the other arguments.";
	}

	DOpus.Output(str);
	cmd.RunCommand("Set UTILITY=OtherLog");
}

One caveat is commands with < characters may be interpreted by the Script Log as trying to use HTML-like codes (for bold, font color, etc.). But using that character is quite rare in commands you'd usually run from an Opus button, so hopefully it's never an issue.

Thanks for the responses.

It would make sense to me for there to be an @log modifier that resolves the arguments and outputs the final command to the script log. It would make everything so much easier.

With the script, instead of @log it's just Out O. Not quite as good but almost, and works right now.