Page 2 of 5
Re: <pfaitem> items are passed one-by-one?
Posted: 17 Mar 2015 04:08
by bdeshi
binocular222 wrote:I simplified the PFA example to stress my point: PFA passes items one-by-one even to :: script
That should be changed.
<pfaitem> always does that. And it's actually correct by definition (it's not <pfaitem
s>)
Anyways, no matter how it's return changed, it will still be called again and again for each selected PFA-matching item.
That's why I said a better solution might be
SammaySarkar wrote:PFA can benefit from a mechanism where the PFA (script) is called only once, by some kind of notation like the existing |-prefix to disable auto-execute.
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 04:24
by binocular222
Now, I'm settled with this PFA (a big thanks to Sammy):
{:Media}>:: if !isset($count) {$allsels = <get selecteditemspathnames |>; $matches = formatlist($allsels, 'fns', '|', <get genericfiletype "{:Media}" "|">); perm $count = gettoken($matches,'count','|'); openwith "<get alias Media>\Media Player Classic HomeCinema\x%osbitness%\mpc-hc.exe",, $matches; }; else { $count--}; if ($count == 1) {unset $count;}
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 05:39
by bdeshi
Nobody will call that a simple solution.
We need a run-once PFA switch!
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 07:14
by admin
I still don't get it. Please show me a minimal reproducible code example where multiple instances are called.
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 07:28
by binocular222
TheQwerty wrote:With that PFA & UDC...
Open With... / POM / UDC (single instance) - XY opens a single instance of MPC with the list of selected items as arguments.
Open Selected Item(s) / UDC (multiple instances) - XY opens an instance of MPC for each selected item, the order in which MPC receives them is unpredictable and a bit of a race condition.
In both cases XY orders the selected items by starting at the focused item (even if it is not selected), goes down/right to the next item, and wraps around the list until all selected items are covered. I believe this is also the order used for the <items> and <selitems> variables.
(At least in my experience - correct me if wrong, Don.)
The problem is not about multiple instance.
It's the target application (in my case is MPC-HC) maybe unable to handle a stream of <pfaitem> from XY (maybe the send speed is too fast ?!), resulting in a disorder. Sammy's workaround is simply aggregate all <pfaitem> into a single argument to pass to mpc-hc.exe.
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 09:32
by bdeshi
admin wrote:I still don't get it. Please show me a minimal reproducible code example where multiple instances are called.
No, it's just that the PFA target script/program executed again and again for each selected item (that matches the pfa pattern)
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 11:30
by admin
Well, as I said before this does not happen (here). If multiple instances of the program are opened that this is the program's decision. XY calls it just once.
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 13:37
by bdeshi
XY calls it just once, but once for each item. Without exception. I'm saying there could be an exception to this behavior, at least for scripted PFAs. Because often that script can take care of multiple selection.
Select a bunch of txts and try this pfa.
Code: Select all
+txt>::echo "I keep repeating!<crlf 2><pfaitem>";
propose:
Code: Select all
+>txt>::echo "I want to show up only once! <get SelectedItemsPathNames |>"; // the > is just a suggestion
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 15:02
by admin
No, it does not repeat anything. It's just called once for the focused item.
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 15:08
by binocular222
Really? Did you select multiple .txt files?
My XY repeat the message box for every .txt file selected
Tested on fresh
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 15:23
by admin
Ah, you are using "Open Selected Items"?
I was using "Open With..."
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 15:36
by binocular222
I use "Open selected Item" #160
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 15:40
by bdeshi
and I just ENTERED.

Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 15:50
by admin
OK, ENTER by default calls "Open Selected Items" (menu File). This will indeed always open each selected item individually in a loop. Has always been like this since day one.
Re: <pfaitem> items are passed one-by-one?
Posted: 20 Mar 2015 16:03
by binocular222
Any plan to change this?