Page 3 of 3
Re: popupmenu - Add nested submenus
Posted: 26 Feb 2022 23:21
by klownboy
Yes, I'm using v0.3. I'm stepping through it now and I'll get back (i.e., steps / unstep before and after those two lines). It appears the first $p_tabs is $p_tabs along with C: $p_tabs|C:|... on the first run (in my case C:) due to
$p_tabs .= "|" . $tabFolder;
EDIT: The first $p_tabs should be the first tab not $p_tabs|C:|... , but that's probably not the issue. I can tell it's being reset before the next pane.
Re: popupmenu - Add nested submenus
Posted: 26 Feb 2022 23:29
by highend
That shouldn't be possible because of global $p_tabs = "";
Re: popupmenu - Add nested submenus
Posted: 27 Feb 2022 01:19
by klownboy
The issue went away once I added global $p_tabs;under the function line. So, it looks like that $p_tabs wasn't seen as initialized as "". That's why I was seeing $p_tabs|C:|... when stepping through the script. I'm not an expert on user-defined functions, but I didn't think you had to do that. Possibly because it was not only initialized but assigned as well
global $p_tabs = "";? Thanks again highend for making that script faster and more viable.
Re: popupmenu - Add nested submenus
Posted: 27 Feb 2022 07:46
by highend
The issue went away once I added global $p_tabs;under the function line
That's what I meant, you aren't using the latest version in that post

Re: popupmenu - Add nested submenus
Posted: 27 Feb 2022 10:40
by Horst
Thanks for the dual pane version
but I always get the following error
---------------------------
XYplorer 22.90.0100
---------------------------
The following source item does not exist:
C:\Temp\Test\$selectedItems
Click OK to go on anyway, or Cancel to terminate the file operation.
---------------------------
OK Cancel
---------------------------
Its trying the following for a copy

- Screenshot - 27.02.2022 , 10_39_53.png (2.33 KiB) Viewed 2731 times

- Screenshot - 27.02.2022 , 10_42_24.png (34.71 KiB) Viewed 2731 times
Re: popupmenu - Add nested submenus
Posted: 27 Feb 2022 10:54
by highend
Try v0.4
Code: Select all
/*
******************************************************************************
@Author : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-02-27 10:53:08
@Function: Copyto, moveto, backupto to tab folders [operation as root]
@Tags : <empty>
@Version : v0.4
******************************************************************************
*/
$iconFolder = ":showfolders";
$iconCopy = ":copyto";
$iconMove = ":moveto";
$iconBackup = ":backupto";
$selectedItems = <get SelectedItemsPathNames |>;
global $p_tabs = "";
end (!$selectedItems), "No item(s) selected, aborted!";
$dp = get("#800");
$fullMenu = "";
$roots = "copyto|moveto|backupto";
$menu = BuildTabEntries("a", $selectedItems);
if ($dp) { $menu .= <crlf> . BuildTabEntries("i", $selectedItems); }
end (!trim($menu, <crlf>)), "No valid destination tab(s) open, aborted!";
foreach($root, $roots, , "e") {
switch (recase($root)) {
case "copyto" : $fullMenu .= <crlf> . "Copy <selected items> here..." . "<:><:>" . $iconCopy . <crlf> . replace($menu, "__OP__", "copyto"); break;
case "moveto" : $fullMenu .= <crlf> . "Move <selected items> here..." . "<:><:>" . $iconMove . <crlf> . replace($menu, "__OP__", "moveto"); break;
case "backupto": $fullMenu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup . <crlf> . replace($menu, "__OP__", "backupto"); break;
}
}
$selection = popupnested($fullMenu, 6:=<crlf>, 7:="<:>");
if ($selection) { load $selection, , "s"; }
function BuildTabEntries($pane, $selectedItems) {
global $p_tabs;
$indent1 = <space 2>;
$indent2 = <space 4>;
$curPath = <curpath>;
if ($pane LikeI "i") { focus "PI"; }
$tabs = get("tabs", "|");
$cntTabs = gettoken($tabs, "count", "|");
$menu = "";
while ($i++ < $cntTabs) {
$tabFolder = tab("get", "path", $i);
$tabFolderSubs = quicksearch("/d /md=0", $tabFolder);
$tabFolderAndSubs = $tabFolder . <crlf> . $tabFolderSubs;
$tabFolderAndSubs = formatlist($tabFolderAndSubs, "f", <crlf>,"!*Recycle*<crlf>*System Vol*<crlf>*REAgent<crlf>*Recovery");
if ($tabFolder LikeI $curPath) { continue; } // Skip tabs with the same current path
if (strpos($p_tabs, "|$tabFolder|") != -1) { continue; } // Skip duplicate tab paths
$info = tab("get", "name", $i);
$icon = gettoken($info, 2, "|");
if (!$icon) { $icon = ":showfolders"; }
if ($tabFolderSubs) {
$menu .= <crlf> . $indent1 . $tabFolder . "<:><:>" . $icon . "<:>";
} else {
$dataTab = "__OP__" . " " . quote($tabFolder) . ", " . quote($selectedItems) . ", , 2, 2;";
$menu .= <crlf> . $indent1 . $tabFolder . "<:>" . $dataTab . "<:>" . $icon . "<:>";
}
foreach($sub, $tabFolderAndSubs, <crlf>, "e") {
if ($tabFolderSubs) {
$dataSub = "__OP__" . " " . quote($sub) . ", " . quote($selectedItems) . ", , 2, 2;";
$menu .= <crlf> . $indent2 . $sub . "<:>" . $dataSub;
} else {
$menu .= <crlf>;
}
}
$p_tabs .= "|" . $tabFolder;
}
$p_tabs .= "|";
if ($pane LikeI "i") { focus "PI"; }
return trim($menu, <crlf>);
}
Re: popupmenu - Add nested submenus
Posted: 27 Feb 2022 11:40
by Horst
Thanks, 0.4 works

Re: popupmenu - Add nested submenus
Posted: 27 Feb 2022 12:06
by klownboy
highend wrote: ↑27 Feb 2022 07:46
That's what I meant, you aren't using the latest version in that post
Weird because I had redownloaded v0.3 last night, but at that time, it didn't have the global after the function statement until I added it. Anyway, all set now. I ran v0.4 in dual with no issues. hanks.