SC: Load hidden subs?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

SC: Load hidden subs?

Post by bdeshi »

Can the load SC load hidden subs? If not, consider this a wish.

I tried something like this, it didn't work.

Code: Select all

"A menu item"
 //code
"Parent menu item"
 load *, "sub1;sub2", s;
"_subitem1 : sub1"
 //code
"_subitem2 : sub2"
 //code
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

SammaySarkar wrote:Can the load SC load hidden subs?
Place the underscore on the label instead of the caption:

Code: Select all

"A menu item"
 //code
"Parent menu item"
 load *, "_sub1;_sub2", s;
"subitem1 : _sub1"
 //code
"subitem2 : _sub2"
 //code
It might be a bug that it hides them when only the caption is underscored - not sure though. :?

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Minor scripting related wishes (a generic thread)

Post by PeterH »

TheQwerty wrote:It might be a bug that it hides them when only the caption is underscored - not sure though. :?
No bug, but should be this way, I think.

As the caption describes the text in the selection list, while hidden says it isn't shown there. So a caption in this place doesn't seem to make sense at all - and the "hidden" identifier belongs to the label.

(Hope I expressed it good enough...)

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

PeterH wrote:As the caption describes the text in the selection list, while hidden says it isn't shown there. So a caption in this place doesn't seem to make sense at all - and the "hidden" identifier belongs to the label.
Right, but the caption does make sense since specifying a label of a hidden script makes it visible and the caption is then displayed.

An interesting, albeit likely never used, aspect of the current behavior is it actually provides 3 levels of visibility:
  1. Visible by Default
  2. Invisible by Default, but Visible by Label
  3. Always Invisible
For instance in this example scripts '_three' and '_four' are always invisible no matter how hard we try to show them. Though you can also still execute them:

Code: Select all

"Load Menu" load '*', 'one;_two;three;_four', 's';
"Load Menu Harder" load '*', 'one;_one;two;_two;three;_three;four;_four', 's';
"Load All" load '*', '*', 's';
-
"Load Three" load '*', 'three', 's';
"Load Four" load '*', '_four', 's';
-
"one : one" Status 'one';
"two : _two" Status 'two';
"_three : three" Status 'three';
"_four : _four"  Status 'four';
The reason I think this is a bug is because I don't think it was ever intended (and certainly not documented) that an underscored caption will take precedence over the label's visibility.

That said I'm perfectly okay with it not getting fixed and this just being a new trick. ;)

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Minor scripting related wishes (a generic thread)

Post by PeterH »

Too much strange things - I'll try to tell one by one :-(

The 3rd operand of load as 's' says: "interpret 1st operand as script text" - so here a script with command '*' should have been executed???
This seems to be a bug - though making sense :-)
The operand should be 'f' here (or nothing) to execute a script from a 'f'ile. Specify 'f' as 3rd operands, and it works as well.
(I think the first operand '*' brings XY to ignore the 3rd operand?)

Next: from help:
Hidden scripts can be executed but are not shown in the script file's popup menu. To hide a script simply prefix an underscore to the caption or label (a hidden script does not need a caption anyway).
(I didn't know the "caption or label" part at all!)

Next: seen from an example: the labels date and _date are disjunct.
(I.e. _date isn't hidden date, but only (hidden) _date) So: many labels of the 2nd line make no sense, as they are unknown!

And, for me: if any label (hidden or not) is explicitely shown in the list of labels, it's caption is meant to be shown.


OK: I rarely use load with a list of labels - either no label, or exact one. So it's OK for me if, on an underscored label, it's entry is not shown in the selection list.
(In other words: till now I didn't have any problem with it :biggrin: )


I hope I didn't forget something... :roll:

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

PeterH wrote:The 3rd operand of load as 's' says: "interpret 1st operand as script text" - so here a script with command '*' should have been executed???
* is a special case resource saying load the current resource. Yes, in this case the third argument is not needed and should be omitted. :oops:
PeterH wrote:To hide a script simply prefix an underscore to the caption or label (a hidden script does not need a caption anyway).
(I didn't know the "caption or label" part at all!)
This is why I could see the current behavior being considered a bug - the docs say it can be either but that's not exactly true.
PeterH wrote:if any label (hidden or not) is explicitely shown in the list of labels, it's caption is meant to be shown.
Which means you now see it as a bug. :P


I can see some interesting uses for the current tri-state visibility but they can all be done in other ways just as easily.

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Minor scripting related wishes (a generic thread)

Post by PeterH »

TheQwerty wrote:
PeterH wrote:if any label (hidden or not) is explicitely shown in the list of labels, it's caption is meant to be shown.
Which means you now see it as a bug. :P
Thought 3 times about the answer. Decided to say no :biggrin:

I think it's not the question of :bug: , but of priority. If you explicitely request display of a hidden label, the explicit request can (and I want to say: should) override the 'hidden' attribute.

So just a (minor) wish. 8)

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by bdeshi »

Hey, give my wish back! :mrgreen:
Now that everything's clear thanks to TQ (once again), I have no problem if load stays as is.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Minor scripting related wishes (a generic thread)

Post by PeterH »

SammaySarkar wrote:Hey, give my wish back! :mrgreen:
Now that everything's clear thanks to TQ (once again), I have no problem if load stays as is.
Did you think of this:
SammaySarkar wrote:Can the load SC load hidden subs? If not, consider this a wish.
If you mean the wording "Can the load SC load hidden subs?" you are wrong: not what I wished :P
And it can load them - no problem here :biggrin:

But from your example I can read now that you talk about showing a selection list for load containing hidden entries - here our wishes meet. But from your wording I didn't understand it this way :roll:

So result: we both wish that explicitely mentioned hidden entries (in load list) should be shown :D
(OK: I don't really wish - I only say it would make sense :ninja: )

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by bdeshi »

Well, I feel you're now trying to confuse me... :ninja: :eh:
Load cannot load a sub at all if the caption is _-ed ( :whistle: )
And yes, I did wish that SC load be able to load those hidden subs, just like SC sub can. (btw, sub can load by both hidden captions and hidden labels)
Therefore our wishes do meet. :D :D
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Minor scripting related wishes (a generic thread)

Post by PeterH »

SammaySarkar wrote:Well, I feel you're now trying to confuse me... :ninja: :eh:
Load cannot load a sub at all if the caption is _-ed ( :whistle: )
And yes, I did wish that SC load be able to load those hidden subs, just like SC sub can. (btw, sub can load by both hidden captions and hidden labels)
Therefore our wishes do meet. :D :D
Are we talking about the same?
To load a sub I specify the label of this one sub in a load command. And if this label exactly matches the label of the wanted sub (may it or it's caption or both be underscored) it will be executed. Just tested this with:

Code: Select all

"main1" load "*", "_aa";
"main2" load "*", "a";
"main3" load "*", "_a";
"_aa : _a" echo "aa a";
Here main3 is correct and works. You may delete _ from the label in the last line, then main2 will work.

So I'd say: calling is ok - as long as there's no selection list.

Can we agree on this?

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: SC: Load hidden subs?

Post by bdeshi »

My mistake. I was confused. :oops:
You're right.
So, I get it now, loading a single hidden sub works, but there's a bug with SC load and more than one hidden sub.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: SC: Load hidden subs?

Post by TheQwerty »

I really think my last script perfectly illustrates things:

Code: Select all

"Load Menu"        load '*', 'one;_two;three;_four';
"Load Menu Harder" load '*', 'one;_one;two;_two;three;_three;four;_four;five;_five;six;_six;seven;_seven';
"Load All"         load '*', '*';
-
"Load One"   load '*', 'one';
"Load Two"   load '*', '_two';
"Load Three" load '*', 'three';
"Load Four"  load '*', '_four';
"Load Five"  load '*', 'five';
"Load Six"   load '*', '_six';
"Load Seven" load '*', 'seven';
-
-
"one : one"      Status 'one';
"two : _two"     Status 'two';
"_three : three" Status 'three';
"_four : _four"  Status 'four';
"five"           Status 'five';
"_six"           Status 'six';
_"seven"         Status 'seven';
As you can see in the 'Load Menu', 'Load Menu Harder', and 'Load All' scripts that if the load results in a menu being shown then any script with a caption starting with an underscore will not be displayed regardless of whether its label starts with an underscore.

However, 'Load Three', 'Load Four', and 'Load Six' demonstrate that scripts with underscored captions can still be loaded so it only impacts the displayed menu.

EDIT: Additionally, while placing the underscore before the quotes (case seven) will hide the script from the default menu, it also corrupts the caption when displayed, cannot be called explicitly, or executed at all since it results in an '_' is not a valid script command. error.
/edit

What does this mean?

Today there are 3 states of visibility:
  1. Visible
    • Neither caption nor label start with underscore.
    • Any time these scripts are part of a menu they are shown.
  2. Hidden by label
    • Label starts with an underscore.
    • If present the caption does not start with underscore.
    • These scripts are only shown in a menu when specified by label or when using the show all label ('*').
  3. Hidden by caption
    • Caption starts with an underscore.
    • Whether a label is present or starts with an underscore does not matter.
    • These scripts will never appear in a menu, even if specified by label.
In all cases an individual script can be loaded and executed by itself - the visibility only affects whether or not it is shown in a menu.

EDIT 2: The above is not entirely true since XY will automatically execute a script if it is the only one visible within the resource - and consequently will show a menu when more than one is visible.
/edit2


Now the question becomes is it...
1) A feature that allows us to completely hide a script by underscoring its caption.
or
2) A bug since specifying the label should show the script regardless of its visibility.



EDIT: Added some additional cases to illustrate captions without labels and malformed hiding.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: SC: Load hidden subs?

Post by bdeshi »

Thanks, got it.
I'd also forgotten executing a script isn't the same as displaying it. :oops:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply