Script file: icons & submenus

Features wanted...
Post Reply
jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Script file: icons & submenus

Post by jacky »

Two more things I'd like to see in script files :

:arrow: Icons.
This has been mentioned before a few times I think, but alongside caption & label a new parameter icon would be great. Ideally it could be an XY constant (for internal icon) or just a path/name (w/ relative syntax to script file location) to a file, with the usual ,<index> support.

There's no question that spotting one little icon goes much faster than having to actually read words on menu items, and I would really like to be able to add a couple of icons on a few script files/menus of mine.

:arrow: Submenus.
Right now we have to use separated menus, but I wonder if it would be possible to use simply submenus. Could a syntax like this work ?

Code: Select all

"Menu 1"
  msg "1";
"Menu 2"
  "Menu 2A"
    msg "2a";
  "Menu 2B"
    msg "2b";
  -
  "Cancel"
"Menu 3"
  msg "3";
-
"Cancel"
I know each line of a script doesn't have to have the same indentation prefix, but even if that only allowed one level of submenu that would already be pretty nice, no? (Though if there was a rule that every line of the submenu must start with the exact same indentation as the first one, to allow more than one level, that'd be even better, obviously!)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66309
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Script file: icons & submenus

Post by admin »

jacky wrote:Two more things I'd like to see in script files : ...
Yes, nice! But I have to postpone this to after Dual Pane. I'm now entering DP meditation mode and this may take a while... and not saying that I like it but it seems to be the only way to get to the top.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Script file: icons & submenus

Post by jacky »

admin wrote:
jacky wrote:Two more things I'd like to see in script files : ...
Yes, nice! But I have to postpone this to after Dual Pane. I'm now entering DP meditation mode and this may take a while... and not saying that I like it but it seems to be the only way to get to the top.
Understood. One thing I'd like you to squeeze in before if that's possible : I'd love a way for a script to abort execution given a certain condition. Something like assert if you want, but without warning to the user or anything. E.g.

Code: Select all

"Script"
  abort confirm("Are you sure ?");
  // something terrible
Right now to do this, we have to for example use sub, calling either the "real" script or an empty one, making things not as easy to work with, or not as nice-looking

Code: Select all

"Script"
  sub (confirm("Are you sure ?")) ? "_script" : "_nothing";
"_script"
  // something terrible
"_nothing"
Ideally, this command abort would also have an extra param: 0 = [Default] abort this script only, 1 = abort the whole script batch (i.e. like assert or when a user press Cancel on input)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66309
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Script file: icons & submenus

Post by admin »

jacky wrote:
admin wrote:
jacky wrote:Two more things I'd like to see in script files : ...
Yes, nice! But I have to postpone this to after Dual Pane. I'm now entering DP meditation mode and this may take a while... and not saying that I like it but it seems to be the only way to get to the top.
Understood. One thing I'd like you to squeeze in before if that's possible : I'd love a way for a script to abort execution given a certain condition. Something like assert if you want, but without warning to the user or anything. E.g.

Code: Select all

"Script"
  abort confirm("Are you sure ?");
  // something terrible
Right now to do this, we have to for example use sub, calling either the "real" script or an empty one, making things not as easy to work with, or not as nice-looking

Code: Select all

"Script"
  sub (confirm("Are you sure ?")) ? "_script" : "_nothing";
"_script"
  // something terrible
"_nothing"
Ideally, this command abort would also have an extra param: 0 = [Default] abort this script only, 1 = abort the whole script batch (i.e. like assert or when a user press Cancel on input)
Okay, good idea. I did it like this:

Code: Select all

    + Scripting got a new command.
      Name:   End
      Action: Terminate a running script.
      Syntax: end condition, [message], [scope=0]
        condition:  if False (0) then script is ended
                    else nothing happens
        [message]:  message before ending
        [scope]:    0: [default] end whole script stack
                    1 (or any other value): end this script
      Examples:
        ::end 1==1; msg "Still here!";  //"Still here!"
        ::end 1==2; msg "Still here!";  //ends silently
        ::end 1==2, "Bye!"; msg "Still here!";  //"Bye!"

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Script file: icons & submenus

Post by jacky »

admin wrote:Okay, good idea. I did it like this:

Code: Select all

    + Scripting got a new command.
      Name:   End
      Action: Terminate a running script.
      Syntax: end condition, [message], [scope=0]
        condition:  if False (0) then script is ended
                    else nothing happens
        [message]:  message before ending
        [scope]:    0: [default] end whole script stack
                    1 (or any other value): end this script
      Examples:
        ::end 1==1; msg "Still here!";  //"Still here!"
        ::end 1==2; msg "Still here!";  //ends silently
        ::end 1==2, "Bye!"; msg "Still here!";  //"Bye!"
Excellent! Thanks a lot :D I'll let you slide to the dark side now... :P ;)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66309
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Script file: icons & submenus

Post by admin »

jacky wrote:
admin wrote:Okay, good idea. I did it like this:

Code: Select all

    + Scripting got a new command.
      Name:   End
      Action: Terminate a running script.
      Syntax: end condition, [message], [scope=0]
        condition:  if False (0) then script is ended
                    else nothing happens
        [message]:  message before ending
        [scope]:    0: [default] end whole script stack
                    1 (or any other value): end this script
      Examples:
        ::end 1==1; msg "Still here!";  //"Still here!"
        ::end 1==2; msg "Still here!";  //ends silently
        ::end 1==2, "Bye!"; msg "Still here!";  //"Bye!"
Excellent! Thanks a lot :D I'll let you slide to the dark side now... :P ;)
I wonder if it's counter-intuitive to end when the condition is false. I know it seems to match assert which also gets active when the condition is false, but then assert is semantically sort-of-opposed to end. So I would say it better should end when the condition is true, e.g.

Code: Select all

end $name==""; // abort when name is empty
Makes sense?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Script file: icons & submenus

Post by jacky »

admin wrote:I wonder if it's counter-intuitive to end when the condition is false. I know it seems to match assert which also gets active when the condition is false, but then assert is semantically sort-of-opposed to end. So I would say it better should end when the condition is true, e.g.

Code: Select all

end $name==""; // abort when name is empty
Makes sense?
You know, it's funny because when I first saw the changelog I immediately had the exact same thought, thinking I would have done it to end on true, only to realize that that (a) it matched assert, and (b) it was also matching my example, when used with a confirm("Sure?") ! So I wasn't really sure...

But since either way it's easy enough to "fake" the NOT operator (end confirm("Are you sure?")-1;), it might be better indeed to change that one, yes, seems more logical to read/write "end ([if] condition to end)".
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66309
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Script file: icons & submenus

Post by admin »

jacky wrote:
admin wrote:I wonder if it's counter-intuitive to end when the condition is false. I know it seems to match assert which also gets active when the condition is false, but then assert is semantically sort-of-opposed to end. So I would say it better should end when the condition is true, e.g.

Code: Select all

end $name==""; // abort when name is empty
Makes sense?
You know, it's funny because when I first saw the changelog I immediately had the exact same thought, thinking I would have done it to end on true, only to realize that that (a) it matched assert, and (b) it was also matching my example, when used with a confirm("Sure?") ! So I wasn't really sure...

But since either way it's easy enough to "fake" the NOT operator (end confirm("Are you sure?")-1;), it might be better indeed to change that one, yes, seems more logical to read/write "end ([if] condition to end)".
Yep. Or do like this:

Code: Select all

end confirm("Are you sure to continue?") == 0;

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

Re: Script file: icons & submenus

Post by PeterH »

admin wrote: I wonder if it's counter-intuitive to end when the condition is false. ...
Just another thougt: is it good to create such "complex" command(s), instead of bringing some more basic logic to scripting, like if/then/else, grouping (and loops)? With these easy to understand "basic" language-elements everyone could build his logic flow simply as he wants. Without always reading help for the sequence and meaning of "extended" operands. Like

Code: Select all

if $var1 > 5 then     // bad condition?
 { msg "Abend for ..., will clean-up"; // notify
   delete $temp;     // some cleanup
   end;              // stop execution
 };

admin
Site Admin
Posts: 66309
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Script file: icons & submenus

Post by admin »

PeterH wrote:
admin wrote: I wonder if it's counter-intuitive to end when the condition is false. ...
Just another thougt: is it good to create such "complex" command(s), instead of bringing some more basic logic to scripting, like if/then/else, grouping (and loops)? With these easy to understand "basic" language-elements everyone could build his logic flow simply as he wants. Without always reading help for the sequence and meaning of "extended" operands. Like

Code: Select all

if $var1 > 5 then     // bad condition?
 { msg "Abend for ..., will clean-up"; // notify
   delete $temp;     // some cleanup
   end;              // stop execution
 };
Yes, sure. But it's not that easy. I would have done it already if it would be a matter of some hours. Patience...

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

Re: Script file: icons & submenus

Post by PeterH »

admin wrote:Yes, sure. But it's not that easy. I would have done it already if it would be a matter of some hours. Patience...
Patience? Fot this? No!
But understanding...

OK: just wanted to ask, when I saw that the awaited IF only came "inside" another instruction.
Will wait... :evil:

Post Reply