popupmenu - Add nested submenus

Discuss and share scripts and script files...
klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post 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.
Last edited by klownboy on 26 Feb 2022 23:33, edited 1 time in total.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: popupmenu - Add nested submenus

Post by highend »

That shouldn't be possible because of global $p_tabs = "";
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post 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.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: popupmenu - Add nested submenus

Post 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 :)
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1092
Joined: 24 Jan 2021 12:27
Location: Germany

Re: popupmenu - Add nested submenus

Post 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
Screenshot - 27.02.2022 , 10_39_53.png (2.33 KiB) Viewed 1783 times
Screenshot - 27.02.2022 , 10_42_24.png
Screenshot - 27.02.2022 , 10_42_24.png (34.71 KiB) Viewed 1783 times
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: popupmenu - Add nested submenus

Post 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>);
}
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1092
Joined: 24 Jan 2021 12:27
Location: Germany

Re: popupmenu - Add nested submenus

Post by Horst »

Thanks, 0.4 works :D
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post 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.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply