<pfaitem> items are passed one-by-one?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post 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 <pfaitems>)
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.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post 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;}
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by bdeshi »

Nobody will call that a simple solution. :whistle:

We need a run-once PFA switch!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 66300
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by admin »

I still don't get it. Please show me a minimal reproducible code example where multiple instances are called.

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post 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.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post 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)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 66300
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post 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.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post 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
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 66300
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by admin »

No, it does not repeat anything. It's just called once for the focused item.

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

Really? Did you select multiple .txt files?
My XY repeat the message box for every .txt file selected
Tested on fresh
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

admin
Site Admin
Posts: 66300
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by admin »

Ah, you are using "Open Selected Items"?
I was using "Open With..."

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

I use "Open selected Item" #160
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: <pfaitem> items are passed one-by-one?

Post by bdeshi »

and I just ENTERED. :eh:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 66300
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: <pfaitem> items are passed one-by-one?

Post 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.

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: <pfaitem> items are passed one-by-one?

Post by binocular222 »

Any plan to change this?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply