Page 1 of 1

Script file: icons & submenus

Posted: 22 Nov 2008 15:25
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!)

Re: Script file: icons & submenus

Posted: 22 Nov 2008 15:57
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.

Re: Script file: icons & submenus

Posted: 22 Nov 2008 17:03
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)

Re: Script file: icons & submenus

Posted: 23 Nov 2008 10:55
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!"

Re: Script file: icons & submenus

Posted: 23 Nov 2008 12:52
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 ;)

Re: Script file: icons & submenus

Posted: 23 Nov 2008 14:50
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?

Re: Script file: icons & submenus

Posted: 23 Nov 2008 15:22
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)".

Re: Script file: icons & submenus

Posted: 23 Nov 2008 15:24
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;

Re: Script file: icons & submenus

Posted: 23 Nov 2008 18:18
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
 };

Re: Script file: icons & submenus

Posted: 23 Nov 2008 20:03
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...

Re: Script file: icons & submenus

Posted: 24 Nov 2008 01:32
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: