User commands, templates, flags, and argument order

I have a user command that calls an external script. I need to be able to pass some flags and two folders.

The script takes standard *nix arguments such as -d -v -x -q -R, etc. Is there a way to allow specifying these in the command editor's Arguments, listed as I've specified? I've tried, for example:


but DOpus changes that to uppercase, -D on selecting it from the command editor. So I've tried using a string parameter such as OPTIONS, later referenced as &OPTIONS& in the user command, but of course that shows OPTIONS in the Argument list.

For the folders, I'd like to be able to select two folders from a lister - is there a way I can guarantee they are passed on the command line in the same order they were click selected? (Many Windows programs maintain the selection order.) I suppose if there is no way, I could require a dual lister using src/dst.

Thanks in advance.


[ul][li]For the first part, you can tell Opus to insert specific text if a /S argument is given, and some other text if it is not.

e.g. Set this as the user command:

dopusrt /ArgsMsgBox &BANANA:-d:&

then call it with this:

myusercommand BANANA

It will show a message box with " -d"

Call it again without the BANANA argument, and it will show ""

Actually, it'll be " " with a space on the end, so this is better (but a bit more confusing) as it moves the space into the optional argument:

dopusrt /ArgsMsgBox -d:&

[li]Selected files are passed in the order they appear in the lister, so you'd have to change the sort-order if you didn't click top-to-bottom, I think. Unless there's something clever that can be done (and would only work with exactly two items) where the item with focus (the one most recently clicked), is treated differently. I can't think of a trick that would work, though.

A more clunky way would be to have two commands, one where the script just establishes the first directory and saves it somewhere, the other which provides the script second directory and the script looks up what was saved as the first.

Your idea of using source and destination windows is probably better than either of those ideas.[/li][/ul]

Ok, thanks. I'm having problems passing two arguments though (the first works, but as I add a second, none are passed):

Called: fuzzydelete DEBUG VERBOSE

Usercommand: fuzzydelete

dopusrt /ArgsMsgBox &DEBUG:-d:& &VERBOSE:-d:& {allfilepath$}

The message box only shows:

 fuzzydelete <folder1> <folder2>

The template can't contain spaces. Remove that and it's fine.

Perfect, thanks!

To clarify the results of my testing, you are correct in that items are passed in sort order. Click/Select-order is not used.

Many Windows programs use the click or selection order. This can be very convenient, as it allows a rapid way to ensure one gets the first selected item targeted as the topmost open document, etc.

(I recently commented elsewhere about this very topic:

Opus doesn't keep track of the selection order, selection is a boolean state.

I had never noticed that Explorer (and the File Open dialogs) did that. That explains a lot. It has always seemed random & extremely frustrating to me that Explorer didn't pass things in the order they were listed, and I know a lot of programs (e.g. media players) sort their inputs (and drag & drop lists) as a result of Explorer's behaviour, and the ones that don't get complaints that files are added in weird orders. The order I happen to find & click things is often pretty random or unrelated to the order I want them to be processed (especially when using range-selection). It's even worse given there is no indication of which order things were selected after you have selected them (except in the File Open dialogs where there's a list of names).

Nice to finally understand what's going on there, but I disagree that it'd be a good thing for Opus to emulate.

Actually, I'm not convinced that Explorer does order things in the order they were clicked.

In Explorer, I just ctrl-clicked these files in this order to select them:


I then dragged (from f.txt) on to TextPad and it opened them in this order:


I can't see any pattern there.

Dragging the same things from Opus has TextPad open the files in order, a b c d e f.

The File Open dialog does not track the order you selected, either. The files are listed in the order they are shown, except that the last selected file is always placed at the start of the list (which is completely stupid, IMO; you end up with f a b c d e).

Oh, I then closed the Explorer window and opened a new one, then did the drag & drop test again. Now I get f a b c d e, like with the File Open dialog. I had created some of the files while the old Explorer window was open, so I suspect Explorer drops files in the order it has them in some internal list, and not according to anything sensible or easily predictable.

Maybe Thunderbird does order attachments in the order you click them. If it does it must not be using the standard File Open dialogs to select them as if it is it would not have any way of knowing the order AFAIK. And it doesn't seem to be standard behaviour.

Sorry, I meant the drag order of arguments.

In Explorer, when you select files, the file used to drag will become the first argument. The arguments will then follow the listing order and cycle back around.

DOpus does not do this. The order is always the listing order.

You can confirm this with a simple batch script (below), and a 1/2 or so files (I use 1.txt, 2.txt, etc.). Select the files, but select a particular file and drag it to the .bat script. You'll see the first argument is the one you dragged. The other arguments follow that file, in listing order and cycle around.

@echo off

echo 1: %1
echo 2: %2
echo 3: %3
echo 4: %4
echo 5: %5
echo 6: %6
echo 7: %7
echo 8: %8