Add sub-menu support for scripts
Re: Add sub-menu support for scripts
thanks highend
-
FluxTorpedoe
- Posts: 904
- Joined: 05 Oct 2011 13:15
Re: Add sub-menu support for scripts
Hi’
Still wondering how to avoid this, any idea?
• An extra separator is added to menus for each "_hidden" entry, e.g. (here, one before and two after):
Thanks,
Flux
Still wondering how to avoid this, any idea?
• An extra separator is added to menus for each "_hidden" entry, e.g. (here, one before and two after):
Code: Select all
"_Initialize"
"Top"
"Sub|||1"
sub "_routine";
"_routine"
msg 1;
"_otherroutine"Flux
• Scripts: Session Manager
| SlideShow | Collection Manager | Power Launcher | Akelpad syntax highlighting | ...
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
Whoops, that one slipped my attention. Fix comes... 
FAQ | XY News RSS | XY X
Re: Add sub-menu support for scripts
Similarly take a look at this:admin wrote:Whoops, that one slipped my attention. Fix comes...
Code: Select all
"_Initialize|||99"
echo 'hi';
"Top|||0"
echo 'top';
"Sub|||1"
sub "_routine";
"_routine|||-1"
msg 1;
"_otherroutine|||-1"
msg 2;The list of labels did not match any script in Script resource.
sub
_routine
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
Okay, fix comes. (No mention in change log)
FAQ | XY News RSS | XY X
-
FluxTorpedoe
- Posts: 904
- Joined: 05 Oct 2011 13:15
Re: Add sub-menu support for scripts
Hi’
First of all, thanks a lot for the ultra-fast separator fix!
Working very well, and it was quite easy to convert previous scripted menus—well, the regular embedded ones.
Now… there’s only one piece missing in the "submenus" feature.
———————————————————————————
• Wish:
Have the same "popup >" effect for the parent of submenus created with SC load, e.g.
"Menu|||>"
load $Menu, , "s";
This would enable dynamic and externalized menus.
• Case:
I’ve a "System" button which opens a menu, listing:
– standard entries (e.g. run command line)
– simple submenus (via |||1),
– but also full-featured submenus (Archive, Report…)
These are loaded from dedicated script files since they’re quite comprehensive (Archive > Rar: each item| Rar: each subfolders|…|7Zip…|Zip:…; Report > Folders up to 1/2/3 levels|Folders+Files up to…)
So, trying to embed such scripts gets really messy real quick (even if just the headers with a switch).
(I know, I tried… Hence my delay in replying.)
• Risk:
Longer delay before main menu is displayed (since you’re currently preprocessing it), in case the "load…" is not optimized. But that’s a fair price to pay, IMHO…
Well, an example might be clearer (even if you’ll probably have a better idea of how to implement this).
• Mockup:
Thanks,
Flux
First of all, thanks a lot for the ultra-fast separator fix!
Working very well, and it was quite easy to convert previous scripted menus—well, the regular embedded ones.
Now… there’s only one piece missing in the "submenus" feature.
———————————————————————————
• Wish:
Have the same "popup >" effect for the parent of submenus created with SC load, e.g.
"Menu|||>"
load $Menu, , "s";
This would enable dynamic and externalized menus.
• Case:
I’ve a "System" button which opens a menu, listing:
– standard entries (e.g. run command line)
– simple submenus (via |||1),
– but also full-featured submenus (Archive, Report…)
These are loaded from dedicated script files since they’re quite comprehensive (Archive > Rar: each item| Rar: each subfolders|…|7Zip…|Zip:…; Report > Folders up to 1/2/3 levels|Folders+Files up to…)
So, trying to embed such scripts gets really messy real quick (even if just the headers with a switch).
(I know, I tried… Hence my delay in replying.)
• Risk:
Longer delay before main menu is displayed (since you’re currently preprocessing it), in case the "load…" is not optimized. But that’s a fair price to pay, IMHO…
Well, an example might be clearer (even if you’ll probably have a better idea of how to implement this).
• Mockup:
Code: Select all
"1. Top|||>"
load "Menu.xys";
"2. Top|||>"
load self("file"), "_menu";
"3. Top|||>"
sub "_menu";
"4. Top|||>"
$menu = '"Sub"'.<crlf><tab>.'msg 1;'.<crlf>.'"Sub"'.<crlf><tab>.'msg 2;';
load $menu, , "s";
"_menu"
$menu = <<<MENU
"Sub"
msg 1;
"Sub"
msg 2;
MENU;
load $menu, , "s";Flux
• Scripts: Session Manager
| SlideShow | Collection Manager | Power Launcher | Akelpad syntax highlighting | ...
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
That's not easy at all.
Here is another idea. I did not try it but what if you'd use the include statement instead of load()?
Here is another idea. I did not try it but what if you'd use the include statement instead of load()?
FAQ | XY News RSS | XY X
-
FluxTorpedoe
- Posts: 904
- Joined: 05 Oct 2011 13:15
Re: Add sub-menu support for scripts
Well, I guess include could work just fine!
Hmmm—ok, I know I push my luck a lot but—since load/function won’t work here in combination, I seem to remember that you were planning some include, [labels] now, weren’t you?
Anyway, thanks for the quick feedback!
Hmmm—ok, I know I push my luck a lot but—since load/function won’t work here in combination, I seem to remember that you were planning some include, [labels] now, weren’t you?
Anyway, thanks for the quick feedback!
• Scripts: Session Manager
| SlideShow | Collection Manager | Power Launcher | Akelpad syntax highlighting | ...
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
Oh really, did I?FluxTorpedoe wrote:Hmmm—ok, I know I push my luck a lot but—since load/function won’t work here in combination, I seem to remember that you were planning some include, [labels] now, weren’t you?
FAQ | XY News RSS | XY X
-
FluxTorpedoe
- Posts: 904
- Joined: 05 Oct 2011 13:15
Re: Add sub-menu support for scripts
Well, that was probably a dumb as
idea, since it would mean much work for you, only to get something pretty similar to load, [labels]…
———————————————————————————
Now, regarding external scripts, I suppose include could work—you meant something like that?
But, for dynamic menus, that would quickly become unusable with lots of small inc…
Say, in the case of this simplified example (currently working but without the "popup >"):
Hence the idea of flagging parent menus as a "popable" menus…
Well, not sure if that would make things easier for you, but "parent menus" could just display the extra ">" without pre-processing their submenu, which would only be loaded after the regular mouseover delay.
———————————————————————————
Now, regarding external scripts, I suppose include could work—you meant something like that?
Code: Select all
"Archive"
include "Archive.inc"
// Archive.inc content:
"_Initialize"
...
"Menu 1"
...
"Menu 2"
...
Say, in the case of this simplified example (currently working but without the "popup >"):
Code: Select all
"Show Items"
// ---------<> Show Hidden
if get("#493") {
$Menu = <<<#>>>
"Show Hidden Files and Folders||2"
#493;
#>>>;
} else {
$Menu = <<<#>>>
"Show Hidden Files and Folders"
#493;
#>>>;
}
// ---------<> Show Protected
$Menu = $Menu.<<<#>>>
"..."
#>>>;
load $Menu, , "s";
"..."Well, not sure if that would make things easier for you, but "parent menus" could just display the extra ">" without pre-processing their submenu, which would only be loaded after the regular mouseover delay.
• Scripts: Session Manager
| SlideShow | Collection Manager | Power Launcher | Akelpad syntax highlighting | ...
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
Well, dynamic menus (submenus that are created only on mouseover), that's not supported at all at the moment.
I think you will have to do with Include for a while.
There is this suggestion of relative levels by zhaowu that might come in handy here (and is something I can do with an okay effort): viewtopic.php?p=143536#p143536
I think you will have to do with Include for a while.
There is this suggestion of relative levels by zhaowu that might come in handy here (and is something I can do with an okay effort): viewtopic.php?p=143536#p143536
FAQ | XY News RSS | XY X
-
FluxTorpedoe
- Posts: 904
- Joined: 05 Oct 2011 13:15
Re: Add sub-menu support for scripts
I guessed as much. Definitely not important and not really regular anyway (that’s why I was previously talking about "pre-" dynamic menus that would be preloaded along with all other entries, before the main menu is displayed).admin wrote:Well, dynamic menus (submenus that are created only on mouseover), that's not supported at all at the moment.
Hmmm,admin wrote:There is this suggestion of relative levels by zhaowu that might come in handy here (and is something I can do with an okay effort): viewtopic.php?p=143536#p143536
Well, except for the new include suggestion (but then a non-relative would work too I suppose).
Fine by me already, thanks!admin wrote:I think you will have to do with Include for a while.
But ohhh, now I get it! [Return of the dumb
You’re also talking about that time when you mentioned including local resources, as in include $Menu, "s"?
• Scripts: Session Manager
| SlideShow | Collection Manager | Power Launcher | Akelpad syntax highlighting | ...
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
If we have a file "IncludedMenu.xys" in the Scripts folder:
... then in this script:
... only the first include would work as desired. The second include would not create the included menu under "Sub B" but under "Top B". With relative levels this could be handled.
Code: Select all
"C:|*||1"
"Go to C:\|||2"
goto "C:\";
"Select Calculator|||2" goto "%winsysdir%";
selectitems "calc.exe";
"D:|*||1"
"Go to D:\|||2"
goto "D:\";
Code: Select all
"Top A"
include "IncludedMenu.xys";
"Top B"
"Sub B|||1"
include "IncludedMenu.xys";FAQ | XY News RSS | XY X
-
FluxTorpedoe
- Posts: 904
- Joined: 05 Oct 2011 13:15
Re: Add sub-menu support for scripts
Oh OK, I thought the counter would somehow be reset, thanks for explaining.
So yes, that would make sense for complex external multi-level submenus (as rare as they might be, so probably not a priority…).
But that definitely wouldn’t be as simply useful as an include $Menu now, would it…
OK, OK, I stop!
Have a nice day,
Flux
So yes, that would make sense for complex external multi-level submenus (as rare as they might be, so probably not a priority…).
But that definitely wouldn’t be as simply useful as an include $Menu now, would it…
OK, OK, I stop!
Have a nice day,
Flux
• Scripts: Session Manager
| SlideShow | Collection Manager | Power Launcher | Akelpad syntax highlighting | ...
-
admin
- Site Admin
- Posts: 65327
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Add sub-menu support for scripts
I just added it. Works nicely. Here's a preview of the change log:
Code: Select all
+ Scripting: Now multi-script nesting can be defined with relative levels.
This can be useful when building menus from local resources by use of the
Include statement.
Syntax: A relative level is marked by a prefixed "+" character. The
number following "+" is added to the last defined absolute level.
For example, the following two code samples create identical nested
multi-scripts:
------------------------------------------------------------------------
"A" echo "A";
"B|||1" echo "B";
"C|||2" echo "C";
"D|||1" echo "D";
"B|||2" echo "B";
"C|||3" echo "C";
------------------------------------------------------------------------
"A" echo "A";
"B|||+1" echo "B";
"C|||+2" echo "C";
"D|||1" echo "D";
"B|||+1" echo "B";
"C|||+2" echo "C";
------------------------------------------------------------------------
However, the second sample uses relative levels which allows it to re-use
the same part of code twice:
"B|||+1" echo "B";
"C|||+2" echo "C";
So this part of code could be outsourced to a file say
"IncludedMenuBC.xys" and then be included like this:
------------------------------------------------------------------------
"A" echo "A";
include "IncludedMenuBC.xys"
"D|||1" echo "D";
include "IncludedMenuBC.xys"
------------------------------------------------------------------------
FAQ | XY News RSS | XY X
XYplorer Beta Club