Get item at position
-
tiago
- Posts: 589
- Joined: 14 Feb 2011 21:41
Get item at position
Trying to optimize my navigational capabilities I see it would be very useful to be able to retrieve an item's path by its position in list. More to the point, i'm interested in an item's immediate neighbors. This would save heavy and clumsy full list retrieval. Itematpos() sounded a natural place for it, but it's coordinate driven. Get() enhancement, please...?
Power-hungry user!!!
-
highend
- Posts: 14996
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Get item at position
Could be scripted as a function (with the next beta)... 
E.g.:
This would show the 5 leading, the file itself + the next 5 following items (for the current active pane):
E.g.:
This would show the 5 leading, the file itself + the next 5 following items (for the current active pane):
Code: Select all
text FindNeighbours(7, 5);
function FindNeighbours($pos=1, $range=1) {
$items = listpane(, , , <crlf>);
$count = gettoken($items, "count", <crlf>);
$firstPos = ($pos - $range < 1) ? 1 : $pos - $range;
$lastPos = ($pos + $range > $count) ? $count : $pos + $range;
return gettoken(gettoken($items, $firstPos, <crlf>, , 2), $lastPos - $firstPos + 1, <crlf>, , 1);
}
One of my scripts helped you out? Please donate via Paypal
-
admin
- Site Admin
- Posts: 66678
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Get item at position
Good idea.tiago wrote:Trying to optimize my navigational capabilities I see it would be very useful to be able to retrieve an item's path by its position in list. More to the point, i'm interested in an item's immediate neighbors. This would save heavy and clumsy full list retrieval. Itematpos() sounded a natural place for it, but it's coordinate driven. Get() enhancement, please...?
Just did it:
Code: Select all
+ SC get("item") enhanced: Added an optional parameter to pass the position
of the item in the list (the first position is "1"). If missing the
focused item is returned.
Syntax: get("Item", [pane=a], [pos])
Examples:
echo get("item", , 4); //item at position 4
Also works as variable:
echo <get item 4>; //note the 2 spaces! the "pane" parameter is missing
FAQ | XY News RSS | XY X
XYplorer Beta Club