Re: Add sub-menu support for scripts
Posted: 03 Nov 2016 22:09
thanks highend
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
Code: Select all
"_Initialize"
"Top"
"Sub|||1"
sub "_routine";
"_routine"
msg 1;
"_otherroutine"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
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";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?
Code: Select all
"Archive"
include "Archive.inc"
// Archive.inc content:
"_Initialize"
...
"Menu 1"
...
"Menu 2"
...
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";
"..."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
Fine by me already, thanks!admin wrote:I think you will have to do with Include for a while.
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";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"
------------------------------------------------------------------------