opw62
November 19, 2022, 9:41am
1
Is there a way to add my own filters to show up in the filter bar (above the status bar), or, alternatively remember previously used filters?
Maybe it is there, vainly searched for it.
It would be nice if a regularly used filter could be saved somewhere: no need to type, e.g. something like : ~(file1*|file2*|file3*) each time again, after changing folders or something.
Thanks.
Leo
November 19, 2022, 11:48am
2
You can make buttons / menus / hotkeys for filters you use often, if that would help? They wouldn’t be on the filter bar itself but could be anywhere in toolbars or menus.
opw62
November 20, 2022, 2:26pm
3
After 1,5 hour of trying to figure this out myself, gave up on it. Bad luck.
Leo
November 20, 2022, 3:01pm
4
We can help if you tell us what you’re trying to do.
opw62
November 20, 2022, 3:43pm
5
I wish I knew how to create simple filters like this:
(that's to say, without having to set this up each time)
I might set this up in Preferences > File Operations > Filters.
There is a list of filters there, created a long time ago.
Honestly speaking, I don't use them and in fact forgot how to use them.
Vainly tried to figure this out.
Leo
November 20, 2022, 4:07pm
6
Do you want a toolbar button that applies a specific wildcard?
Or a menu item?
Or a hotkey?
Or something else?
WKen
November 20, 2022, 7:26pm
7
Play.
function OnClick(clickData)
{
var cmd = clickData.func.command;
var filepath = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\CustomFilters.txt"; //File path
if(DOpus.FSUtil.Exists(filepath)) { //Read file
var FSU = DOpus.FSUtil;
var ST = DOpus.Create.StringTools();
var text = FSU.OpenFile(filepath).Read();
var text = ST.Decode(text, "utf-8 bom");
} else {var text = "New Filter\r\n-";}
var myArray = text.split("\r\n");
var opt1 = DOpus.NewVector();
for(i = 0; myArray[i]; i++) {
opt1(i) = myArray[i];
}
var opt2 = DOpus.NewVector(opt1.length);
var dlg = clickData.func.dlg;
//Show menu
dlg.choices = opt1;
dlg.menu = opt2;
var r = dlg.Show();
//If clicking
if (r > 0)
{
//Get Clicked item
var c = opt1(r - 1);
if(c == "New Filter") {
var dlg = clickData.func.Dlg;
dlg.title = "New Filter";
dlg.message = "Enter a new filter";
dlg.buttons = "OK|Cancel";
dlg.max = 256;
dlg.defvalue = "";
dlg.select = true;
dlg.Show();
var input = dlg.input;
if (dlg.result == 0 || input == "")
return;
}
var newFilter = "";
var filecontent = "";
if(c != "New Filter") {
cmd.Runcommand('Set QUICKFILTER="' + c + '"'); //Run an internal command
} else {
if(input != "") {
cmd.Runcommand('Set QUICKFILTER="' + input + '"'); //Run an internal command
for(i = 0; myArray[i]; i++) {
if(input == myArray[i]) {var equal = 1};
//DOpus.Output(newFilter)
}
if(equal != 1) {newFilter = input};
if(newFilter != "" && text != "") {
filecontent = text + "\r\n" + newFilter;
} else {
if(newFilter != "" && text == "") {
var filecontent = "New Filter\r\n-" + "\r\n" + newFilter;
}
}
if(!DOpus.FSUtil.Exists("%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\")) { //Create the path if does not exist
cmd.Runcommand('CreateFolder "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\"');
}
//DOpus.Output(filecontent);
if(filecontent != "") {
var FSU2 = DOpus.FSUtil;
var ST2 = DOpus.Create.StringTools();
var oFileWrite = FSU2.OpenFile(filepath, "wa"); //Save filters
var utf8bom = ST2.Encode(filecontent, "utf-8 bom");
if(oFileWrite.error == 0)
{
oFileWrite.Write(utf8bom)
}
oFileWrite.Close()
}
}
}
}
}
Leo
November 20, 2022, 8:48pm
8
He's unlikely to need anything remotely as complex as that. It will probably be a one-line command. But we need the details of exactly what is wanted and where.
opw62
November 21, 2022, 7:18am
9
Sorry, either a menu item or button.
I tried to set up a filter (see above) but how to invoke it and/or create a button or menu item, no idea.
Leo
November 21, 2022, 11:34am
10
Using your wildcard from above, the command would be like this:
Set QUICKFILTER="~(snag*|capt*|img*)"
See How to use buttons and scripts from this forum - Raw Commands for how to add it to a toolbar.
1 Like
opw62
November 22, 2022, 3:38pm
11
Thank you! That's the one I was seeking.
Wasn't aware of QuickFilter to be frank.
Thanks again and sorry for the delay.
1 Like