Quickfilter based on first x characters in a selected filename

I have created a command as follows that is based on a hypothetical file I selected in a panel.

Johnson's Talk on how to be more organised.txt

set quickfilter {O!|noext}

I want the filter to show only

Johnson's talk

How do I modify it to pick up say the first 15 characters. In addition, I would like the quickfilter to apply to both panels.

Thanks for any help.

Using a simple script:

function OnClick(clickData)
{
	if (clickData.func.sourcetab.selected.count != 1)
		return;

	nameStart = clickData.func.sourcetab.selected(0).name_stem_m.substr(0,15);

	var cmd = clickData.func.command;
	cmd.ClearFiles();
	cmd.RunCommand('Set QUICKFILTER="' + nameStart + '"');

	if (clickData.func.sourcetab.lister.dual && clickData.func.desttab)
	{
		cmd.SetSourceTab(clickData.func.desttab);
		cmd.RunCommand('Set QUICKFILTER="' + nameStart + '"');
	}
}

I ran the above script after I added a first line after I read the help file, as my screen looks a little different from the one you posted which has anothe row above the script Edit, Script Type Jscript etc.

@script jscript

But I got the following error message.

Error at line 3, position 10
Function OnClick(clickData)
^
Expected ';' (0x800a03ec)
Parse error - script aborted

What could I have done wrong?

Keep the @script line but delete the rest, then try pasting it in again from the original text above.

It looks like it got pasted when in VBScript mode, which changed the capitalisation of things like "function" to "Function", and JScript is (annoyingly) case-sensitive.

(The UI differences are Opus 11 vs Opus 12.)

I created a completely new button and pasted in the script

@script jscript 

function OnClick(clickData)
{
	if (clickData.func.sourcetab.selected.count != 1)
	return;

	nameStart = clickData.func.sourcetab.selected(0).name_stem_m.substr(0,15);

	var cmd = clickData.func.command;
	cmd.ClearFiles();
	cmd.RunCommand('Set QUICKFILTER="' + nameStart + '"');

	if (clickData.func.sourcetab.lister.dual && clickData.func.desttab)
	{
		cmd.SetSourceTab(clickData.func.desttab);
		cmd.RunCommand('Set QUICKFILTER="' + nameStart + '"');
	}
}

When I clicked the Button it gave an error message.

Script Engine 'jscript ' could not be opened

Much appreciate your help.

It looks like you have an errant character (a space or a tab, maybe) on the end of the @script jscript line. Notice how the pasted error message has a gap between the t and the final quote:

Thank you.

However, now there's a new error message.

Error at line 8, position 2
'func.sourcetab.selected(...).name_stem_m' is null or not an object (0x800a138f)

Change it to name_stem (name_stem_m is new for Opus 12; sorry for not spotting that myself).

Works.

Thank you for your precious help.:relaxed: