Why working scripts don't work elsewhere?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Locked
sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Why working scripts don't work elsewhere?

Post by sl23 »

I currently have a list of Favourite Folders. The list is quite long. So I tried to save them to a script and add sub-folders using the menu command, as I have done for the Main Menu:

Code: Select all

$menu = <<<MENU
              File;;<xy>
                #100
                  #101
                  [i]etc...[/i]
                  MENU;
       popupnested($menu);
I've made a copy of this menu and saved as Bookmarks.xys. I'm removing all the existing code from it and replacing with all the Favourite Folders button. But It's not working as it should. Why do I need to rearrange the script if I move working code from one place to another? Is it because the code isn't compatible with the menu?

In Favourite Folders, this works:

Code: Select all

"C:|<xyicons>\Win10 C drive.ico" #340; goto "C:\";
"D:|<xyicons>\Win10 drive.ico" #340; goto "D:\";
"E:|<xyicons>\Win10 drive.ico" #340; goto "E:\";
"Documents|<xyicons>\This PC.ico" #340; goto "%personalreal%";
D:\SyMenu\SyMenu.exe
All icons show in menus and they open as expected. But when I move the exact same code to the menu it all goes wrong. I can get it to work, but no matter what I do, I can't show proper names and icons together:

Code: Select all

$menu = <<<MENU
              "C:" #340;;<xyicons>\Win10 C drive.ico;
              "D:|<xyicons>\Win10 drive.ico" #340; goto "D:\";
              "E:|<xyicons>\Win10 drive.ico" #340; goto "E:\";
              "E: SyMenu" tab("new", "E:\SyMenu\");
            MENU;
       popupnested($menu);
I've tried just about everything I can think of, but it just refuses to work AND show names and icons.
What am I doing wrong?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Why working scripts don't work elsewhere?

Post by highend »

Favorite folders does not support a (multiline) script approach per entry, it's one entry per line for each folder entry.

How else should it be possible to sort these entries via the list management tool "favorite folders" entry?
One of my scripts helped you out? Please donate via Paypal

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

Sorry, I missed out that I am using this script (Bookmarks.xys) via a toolbar button.

All I'm trying to achieve is to click a toolbar button to open my list of folders with some sub-categories too.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Why working scripts don't work elsewhere?

Post by highend »

And? You're already doing this with the first script?
One of my scripts helped you out? Please donate via Paypal

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

No as it doesn't allow sub-categories.

Basically I want all system shortcuts in a sub-folder in the favourite folders menu, but you can only put single line scripts in there so I thought about just using a separate script.xys file and an ordinary button to do the job.

I can get the menu to show the folders but no icons and or names, just paths or the #340 command, as I want them all to open in New tabs NOT the current tab.

Not really sure why this isn't the default in every file manager tbh. If you're working on something in one tab, why would you want to use that tab to open a bookmarked folder, or use more mouse clicks to open tab then bookmark?

I often install/update portable apps manually and need to check if apps are using the system folders for settings. SyMenu can clean there folders by telling apps to store this data in the apps folder. Doesn't always work, but mostly it does.

This means I need the tab that's open and constantly have to open new tabs and open bookmarks in XYplorer. Cubic explorer has an option to open drives and bookmarks automatically in a new tab and makes the whole process so much easier. I would like to replicate this as part of the switch to XYplorer.

Thank you.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Why working scripts don't work elsewhere?

Post by highend »

Exactly, the inbuilt favorites don't support any form of hierarchy.

You are free to temp save the XYplorer.ini, read out the existing favorites and built your desired menu with your own script. Anything else doesn't work in this situation...

No, I don't answer any questions regarding that script, everything's commented^^

Code: Select all

    // Store current XYplorer.ini as a temp file
    $tmpIni = "%TEMP%\~XY.ini";
    savesettings 1, $tmpIni;

    // Get favorite section entries
    $favItems = getsectionlist("Favorites", $tmpIni);

    // Get only Fav<x> entries, not the "Count=<x>"...
    $favItems = regexmatches($favItems, "^Fav.+?(?=\r?\n|$)", <crlf>);

    // Build menu entries out of them
    $menu = "";
    foreach($favItem, $favItems, <crlf>, "e") {
        // Strip "Fav<x>="
        $favItem = regexreplace($favItem, "^fav\d+=");

        // Trim leading and trailing quotation mark (not multiple ones)
        $favItem = regexreplace($favItem, "^[""]|[""]$");

        // "Caption|Icon" <commands>
        // E.g.: "C:|<xyicons>\Win10 C drive.ico" #340; goto "C:\";
        // I'm assuming that YOU always use the same schema for all entries^^
        $captionAndIcon = regexmatches($favItem, "^[""].+?[""]", <crlf>);
        $caption        = trim(gettoken($captionAndIcon, 1, "|"), '"');
        $icon           = trim(gettoken($captionAndIcon, 2, "|"), '"');

        // Command part
        $commands = trim(replace($favItem, $captionAndIcon));

        // Build popupnested() entries out of it
        // Caption|Data|Icon|[State]
        // Start at root level, no indention here
        $menu .= $caption . "|" . $commands . "|" . $icon . <crlf>;
    }


    // Whatever your "System shortcuts" are or where they come from...
    $systemShortcuts = <<<>>>
    >>>;

    // Glue the formerly create $menu part with your system shortcuts together^^
    if ($systemShortcuts) { $menu .= <crlf> . $systemShortcuts; }

    // Display menu and execute it
    $sel = popupnested($menu, 7:="|");
    if ($sel) { load $sel, , "s"; }
One of my scripts helped you out? Please donate via Paypal

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

...
Last edited by sl23 on 16 May 2021 23:19, edited 1 time in total.

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

Thanks but the code was of no use.

The problem remains. Code isn't universal.
This "C:|C:" #340; goto "C:\"; works in a text file script brought up by a custom button. But the exact same code doesn't work in the favourites menu.

So when it is stated that "Caption|Icon" is to be used, it is in fact incorrect as it seems it only works in certain places and NOT in others!

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Why working scripts don't work elsewhere?

Post by highend »

This "C:|C:" #340; goto "C:\"; works in a text file script brought up by a custom button. But the exact same code doesn't work in the favourites menu.
OMFG...

But don't worry, I'll never waste a second of my time again to write even a single line of code for you^^
Animation.gif
Animation.gif (404.94 KiB) Viewed 1035 times
One of my scripts helped you out? Please donate via Paypal

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

The whole point of this discussion is that I know how to create sub menus in a button:

Code: Select all

$menu = <<<MENU
              Window;;<xy>
                #675
                #674
                #665
                -
                #680
                  #683
                  #685
                  #694
                -
                #672
                #673
              -
            MENU;
       popupnested($menu);
Hamburger sub menu:

Code: Select all

More Commands
 ::Character View Current Filename;charview <curname>;
 :mrl
 My Caption for Copy Path;#101;Green.ico
 #102;;:copy //File 
 To Clipboard 
 Item Name(s)
 Go, baby;#1070;:go
But code used in one place can't be used in another place.

I requested help with creating sub menu's. You're code doesn't do that.
So where are the sub menu's?

I am clearly stating I know NOTHING about scripting and you aren't giving any real help so I can learn.
I have repeatedly asked for help on how to make icons and custom names appear in menu's and sub menu's. Instead I get ignored, abused and told to read a help file that is, with the greatest of respect, unhelpful, and you wonder why I got angry and frustrated with you before. I'm not having a go at you, I'm just stating how it is, nothing more. I don't mean to sound like I'm being an asshole, I really just want some simple help with it instead of a complex script I can't fathom.
Last edited by sl23 on 17 May 2021 00:56, edited 1 time in total.

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

For example, why does this work on it's own as single entries in a Bookmarks.xys file:

Code: Select all

"This PC|%computer%" #340; goto "%computer%";
"Documents|%personalreal%" #340; goto "%personalreal%";
"- App Data|*.<DIR>" #340; goto "%USERPROFILE%\AppData\";
"- Program Data|*.<DIR>" #340; goto "%ProgramData%";
"- Program Files 32|*.<DIR>" #340; goto "%ProgramFiles(x86)%";
"- Program Files 64|*.<DIR>" #340; goto "%ProgramW6432%";
But adding it to a menu stops it functioning:

Code: Select all

$menu = <<<MENU
            System Menu
              "This PC|%computer%" #340; goto "%computer%";
              "Documents|%personalreal%" #340; goto "%personalreal%";
              "- App Data|*.<DIR>" #340; goto "%USERPROFILE%\AppData\";
              "- Program Data|*.<DIR>" #340; goto "%ProgramData%";
              "- Program Files 32|*.<DIR>" #340; goto "%ProgramFiles(x86)%";
              "- Program Files 64|*.<DIR>" #340; goto "%ProgramW6432%";
            MENU;
       popupnested($menu);
I can get it to either open a tab but not the specified folder, show icon and name or just name and open tab. Why do I even need to rearrange it all? it should just work as is!

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Why working scripts don't work elsewhere?

Post by sl23 »

With respect highend, the code you wrote is a complex way of doing exactly the same as clicking the favourite folders button. It's not that I don't appreciate your writing it. I just don't see the point as it doesn't do what I have asked for. Not that I'm asking you to write it. I just want to know what I am doing wrong. But it seems impossible to get any response on this forum for the simplest of requests.
:(

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Why working scripts don't work elsewhere?

Post by highend »

I requested help with creating sub menu's. You're code doesn't do that.
So where are the sub menu's?
AGAIN: THE INBUILT FAVORITES DO NOT SUPPORT THAT^^

My script didn't claim to produce submenus out of something that doesn't support them^^ It does combine the existing ones and add WHATEVER YOUR FUC*** "system shortcuts" (even if they are layered) into ONE menu.
I am clearly stating I know NOTHING about scripting and you aren't giving any real help so I can learn.
I have repeatedly asked for help on how to make icons and custom names appear in menu's and sub menu's. Instead I get ignored, abused and told to read a help file that is, with the greatest of respect
I can't read it anymore... The help file is bad, ugly, misinforming and everything else that hinders you from reading it. Got that.

You want to know what you're doing wrong? Consult the fuc**** help file. I know you won't.

Code: Select all

$menu = <<<MENU
            System Menu
              "This PC|%computer%" #340; goto "%computer%";
              "Documents|%personalreal%" #340; goto "%personalreal%";
              "- App Data|*.<DIR>" #340; goto "%USERPROFILE%\AppData\";
              "- Program Data|*.<DIR>" #340; goto "%ProgramData%";
              "- Program Files 32|*.<DIR>" #340; goto "%ProgramFiles(x86)%";
              "- Program Files 64|*.<DIR>" #340; goto "%ProgramW6432%";
            MENU;
       popupnested($menu);
Why doesn't that work in a normal script? Because you didn't read (again) the entry for popupnested() and directly afterwards popupmenu() because popupnested() refers to it regarding syntax.
Can you read the itemlist + sep_item parameter?
If you could you would know why that example fails.

CAPTION
DATA
ICON
STATE


separated by sep_item

"This PC|%computer%" #340; goto "%computer%"; resolves into what regarding these aspects?

Does it have the ICON in the right place? Does your used statement even support multiple internal/script commands?

In case you think that anything resolves to a "yes" answer, no, it doesn't.

Code: Select all

$menu = <<<MENU
            System Menu
              This PC|#340; goto "%computer%";|%computer%
              Documents|#340; goto "%personalreal%";|%personalreal%
              - App Data|#340; goto "%USERPROFILE%\AppData\";|*.<DIR>
              - Program Data|#340; goto "%ProgramData%";|*.<DIR>
              - Program Files 32|#340; goto "%ProgramFiles(x86)%";|*.<DIR>
              - Program Files 64|#340; goto "%ProgramW6432%";|*.<DIR>
            MENU;
       $sel = popupnested($menu, 7:="|");
       if ($sel) { load $sel, , "s"; }
Oh, maybe the right item_sep was used here and maybe the icons are in the correct position and maybe the data that is returned is interpreted correctly?

My script did cover EXACTLY THIS SCENARIO but it was useless...

As I said before, find someone that is willing to help you to learn scripting. I'm not the one. Your constant refuse to read the help file will never lead you anywhere and I'm tired of hearing that the help file is shit. Over and out.
One of my scripts helped you out? Please donate via Paypal

Locked