Select can't handle redundant backslashes

Usually, redundant backslashes in a path are not a problem. Even fsu.Resolve() doesn't clean them up. They can easily appear in paths, because the realpath property of a path object will end with a backslash for root directories.

Unfortunately, Select can't handle them. I think it should be able to.

Button as XML
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
	<label>New Button</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    var fsu = DOpus.FSUtil();</instruction>
		<instruction />
		<instruction>	cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    cmd.RunCommand(&apos;Set UTILITY=otherlog&apos;);</instruction>
		<instruction>    DOpus.ClearOutput();</instruction>
		<instruction>	</instruction>
		<instruction>	var item1 = fsu.Resolve(&apos;D:\\test1.jpg&apos;);</instruction>
		<instruction>	var item2 = fsu.Resolve(&apos;D:\\\\test2.jpg&apos;);</instruction>
		<instruction>	</instruction>
		<instruction>	DOpus.Output(item1);</instruction>
		<instruction>	DOpus.Output(item2);	</instruction>
		<instruction>	</instruction>
		<instruction>	cmd.ClearFiles()</instruction>
		<instruction>	cmd.AddFile(item1);</instruction>
		<instruction>	cmd.AddFile(item2);</instruction>
		<instruction>	</instruction>
		<instruction>	cmd.RunCommand(&apos;Select NONE&apos;);</instruction>
		<instruction>	cmd.RunCommand(&apos;Select FROMSCRIPT&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

P.S.: Select doesn't like forward slashes at all.

We should be able to improve that. It's on our list now.

There is a FileSystemObject.BuildPath method in the Windows scripting objects which can be used to combine path components without having to manually check if slashes are required etc.

The Opus Path.Add method can also do something similar.

Those can help avoid non-canonical path separators, which might cause problems in other places (or outside of Opus).

1 Like

Looks like the Path.Split() method gets confused by redundant backslashes as well:

var cmd = DOpus.Create().Command();
var fsu = DOpus.FSUtil();

cmd.deselect = false;

cmd.RunCommand('Set UTILITY=otherlog');
DOpus.ClearOutput();

var item1 = fsu.Resolve('D:\\test1.jpg');
var item2 = fsu.Resolve('D:\\\\test2.jpg');

DOpus.Output(item1);
DOpus.Output(item2);

DOpus.Output('--');

for (var e = new Enumerator(item1.Split()); !e.atEnd(); e.moveNext()) DOpus.Output(e.item());

DOpus.Output('--');

for (var e = new Enumerator(item2.Split()); !e.atEnd(); e.moveNext()) DOpus.Output(e.item());

DOpus.Output('==');