Code: Select all
But there is no possible easy way to get an index of a tab by its captionIt works for captions, paths, names and data (unresolved paths) and it returns either
the first index only (default) or all indexes (separated by $sep).
Code: Select all
$caption = "D:\";
text getTabIndex($caption, "c", "a");
/* *****************************************************************
* Returns the index of a tab
* Example(s):
* text getTabIndex("C:\Windows");
* Output: 2
* Mode: c (caption = default), p (path), n (name), d (data)
* Ret : f (first only = default), a (all) -> Which index to return
* Sep : "|" (default) -> Separator for multiple indexes
* Returns "0" if no index is found
***************************************************************** */
function getTabIndex($str, $mode="c", $ret="f", $sep="|") {
if !($str) { return 0; }
$mode = replacelist($mode, "c|d|p|n", "caption|data|path|name", "|");
$retVal = "";
while ($i++ < tab("get", "count")) {
$match = tab("get", $mode, $i);
if ($str LikeI $match) {
if ($ret == "f") { return $i; }
elseif ($ret == "a") { $retVal = $retVal . $i . $sep; }
}
}
return ($retVal) ? trim($retVal, $sep, "R") : 0;
}
XYplorer Beta Club