New version. It mimics Recent Locations (shows paths with number) when Sorted and Grouped is No and mimics HotList (No numbers) when Sorting and Grouping is on.
Heredoc resolves the variable names and hence, it wasn't self sufficient to be stored directly with the CTB. Have worked around that and this is self sufficient.
Thanks LittleBig for this script. My UDC is now ready
Code: Select all
"HitList"
perm $P_MRU ;
$var_P_MRU = '$P_MRU' ;
$var_new_limit = '$new_limit' ;
$P_MRU = ($P_MRU == "" )? "|AL:32|SAG:Yes|ACT:Goto|" : $P_MRU ;
$limit = RegExMatches ($P_MRU,"\|AL:WA|\d+") ; //WA is a workaround
$sag = RegExMatches ($P_MRU, "\|SAG:WA|Yes|No") ;
$act = RegExMatches ($P_MRU, "\|ACT:WA|Goto|MoveTo|CopyTo");
$count = 0;
$CleanList = "";
$state = "";
if ( (!get("CountSelected")) && ($act != "Goto")) { $state="|4"; }
foreach($RecPath, get("list_recentlocations"), <crlf>,, "") {
if ($count < $limit) {
if (substr($RecPath,0,2) == "\\" || exists($RecPath) > 0) { //Assume Network paths are available
$count++;
$CleanList = $CleanList . '"' . format($count,"00") . " - " . $RecPath . "| $RecPath" . $state . '" ' . $act . ' "' . $RecPath . '"' . "<crlf>";
}
}
else {
break;
}
}
$CleanList = formatlist($CleanList,"e","<crlf>");
if ($sag == "Yes") {
$Grouped = RegExReplace ($CleanList,"\d+ - (.+)","$1") ;
$Grouped = formatlist($Grouped,"s","<crlf>");
$CleanList = "";
$LastLetter = substr($Grouped,1,1);
foreach($path, $Grouped, <crlf>,, "") {
if ($LastLetter != substr($path,1,1)) {
$CleanList = $CleanList . "-" . <crlf>;
}
$LastLetter = substr($path,1,1);
$CleanList = $CleanList . $path . <crlf>;
}
}
if ($act=="Goto") {$goto="|2" ; $copy="" ; $move="" ; }
elseif ($act=="CopyTo") {$copy="|2" ; $move="" ; $goto="" ;}
elseif ($act=="MoveTo") {$move="|2" ; $goto="" ; $copy="" ; }
$MENU=<<<FOO
"Actual Limit: $limit|:rename"
$var_new_limit = input("New limit:",,$limit)*1;
$var_P_MRU = Replace($var_P_MRU, "AL:$limit|", "AL:".$var_new_limit."|", 1);
"Sorted and Grouped: $sag |:sort"
if ($sag == "Yes") {
$var_P_MRU = RegExReplace($var_P_MRU, "\|SAG:Yes\|", "|SAG:No|", 1);
}
else {
$var_P_MRU = RegExReplace($var_P_MRU, "\|SAG:No\|", "|SAG:Yes|", 1);
}
"Goto|:labels $goto"
$var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:Goto");
"Copy|:labels $copy"
$var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:CopyTo");
"Move|:labels $move"
$var_P_MRU = Replace ($var_P_MRU, "|ACT:$act", "|ACT:MoveTo");
"-"
FOO;
$MENU=$MENU . <crlf> . $CleanList ;
load "$MENU", * , 's';