I am trying to build a toolbar button to launch a text comparer. I works by comparing two files. I see <curitem> but I need access to both items. I would love to use <items>, but it's only available for "Open with" for some reason.
Can anyone help me out?
Thanks in advance!
Get two selected items
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Get two selected items
Welcome to the club!
You can use get('SelectedItemsPathNames', '|') or the <selitems> variable as <selitems '|'> both of which return a pipe-separated list of all selected items.
btw, I use this oddly indented script for launching BeyondCompare with currently selection in one or both panes (or current pane paths (or dropped items)).
You can use get('SelectedItemsPathNames', '|') or the <selitems> variable as <selitems '|'> both of which return a pipe-separated list of all selected items.
btw, I use this oddly indented script for launching BeyondCompare with currently selection in one or both panes (or current pane paths (or dropped items)).
Code: Select all
INCLUDE "inc\in.xyi"; //get the in() UDF from Script Exchange > User Functions Exchange
"BeyondCompare"
//prio: drop > 2xSelxPane > 1xSelxPanes
$app = """<xypath>\..\BeyondCompare\BCompare.exe""";
$files = '""'; $cmd=''; $mode ='';
$dr = replace(<drop>, <crlf>, '|');
$fa = get('SelectedItemsPathNames', '|', 'a');
$fi = get('SelectedItemsPathNames', '|', 'i');
if (gettoken($dr, 'count', '|') == 2) { $files = $dr; }
elseif (gettoken($fa, 'count', '|') == 2) { $files = $fa; }
elseif (gettoken($fa, 'count', '|') == 1)&&
(gettoken($fi, 'count', '|') == 1) { $files = $fa.'|'.$fi; }
else {
$da = get('path','a');
$di = get('path','i');
if (strpos($da,'paper:') != 1)||
(strpos($di,'paper:') != 1) {
$files = $da.'|'.$di;
$mode = "Folder";
}
}
if ($mode == '') {
$type1 = filetype(gettoken($files, 1, '|'));
$type2 = filetype(gettoken($files, 2, '|'));
$type = $type1.'|'.$type2;
if in($type,'Binary|Empty|Cannot|Nofile') { $mode = 'Hex'; }
else {$mode = 'Text';}
}
$files = '"'.replace($files,'|','" "').'"';
$cmd = "/fv=""$mode Compare""";
run "$app $files $cmd";
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
XYplorer Beta Club