New Dialog: Options()

New Dialog: Options()

8

    Mar 28, 2011#1

    It would be nice if the Ecmascript/Javascript folk could implement this, but until then I would hope IDM would throw it into their JS implementation.

    A new dialog a la alert(), confirm(), prompt() called options() called like so:

    //syntax: options(TITLE,DEFAULTCHOICE,CHOICESARRAY)
    //CHOICESARRAY can be numeric-indexed or an associative array
    //return undefined if CANCEL pushed
    var TheChoices = {a:'ChoiceA', b:'ChoiceB', X: 'Exit'};
    var mychoice = options('Make your choice','X',TheChoices);

    When I write some of my UE JS scripts I'd like to present a menu of choices to myself so that I don't have to write a bunch of individual scripts to handle only slightly different situations.

    This has been emailed to IDM support for consideration.

    How many agree that this would be useful?

    6,680583
    Grand MasterGrand Master
    6,680583

      Mar 29, 2011#2

      Although I understand your intention, I don't really understand what your option dialog should look like. What type has the array TheChoices? What should the options dialog look like?

      I don't need such an option dialog for myself, but I think it would be a very useful enhancement for many script writers to have an options dialog.

      The dialog should have:
      1. a title text displayed in the dialog window title,
      2. a request text with up to 3 lines at top of the dialog with using \n in the text to force a line break inside this multiline string,
      3. a list of string items for a listbox.
      The first list item is automatically preselected on opening the dialog which makes a Cancel button unnecessary and additionally has the advantage that no error condition must be handled. The syntax for this option dialog command could be:

      listbox("window title","text above listbox,\nfor example:\nPlease choose line termination type:","DOS","UNIX","MAC");

      The return value of the function is either an integer with value 0 for first option, value 1 for second option, ... or the string selected by the script user. An integer as return value can more easily evaluated, but a string would be easier to read when used in following conditions. Normally an integer is returned by a listbox control.

      I have not sent this to IDM support by email. I have just contributed my idea on such an options dialog here.

      8

        Apr 07, 2011#3

        theChoices, as stated, would be either a Javascript associative array, or a simple numeric-indexed array. Programmer's choice depending on the situation. Associative arrays are quite valid in JS so why restrict to simple arrays?

        As to the request text parameter, good idea, so that the rationale for the dialog can be explained a little further.

        returning undefined on cancel, I think, is still valid (i.e. to quote RUSH from "Freewill": "If you choose not to decide you still have made a choice") and therefore always pre-selecting the first item would reduce functionality. Having a programmer-defined default choice allows the user to simply hit OK (or press Enter) to make the default choice which is good. Also, it may not always be desirable to consider the first item the default (i.e. I work for the Canadian government. If, working on a public or internal app, I were to display a dialog asking "What's your preferred language?" and I defaulted it to "English" I'd get skewered.)

        I was thinking the dialog would have option buttons but a listbox would be fine. An extra parameter could be AllowMultiple boolean which would display a multi-select listbox or checkboxes instead of radio buttons and the return would be an array [of numeric indexes or string key values depending on the Choices array supplied] instead of a single value.

        And, if the programmer decides there is to be no cancel then allow that as a parameter, too. But always have an "OK" or "Continue" button so that the closing of the dialog isn't immediate upon making a choice (which is necessary if allowing multiple).

        The reason I figured for allowing an associative array is that the letters {restrict the array keys to single-letter} can be used as the selectors, like with a console menu.
        ( ) A: ChoiceA
        ( ) B: ChoiceB
        ( ) X: Exit
        or, if Multi-select
        [ ] M: Male
        [ ] T: Tall
        [ ] X: Executive
        {substituting actual radio or checkbox controls for the ( ) and [ ] and including the infoText above that}

        so, extending:
        Syntax could now be:
        var selection = optionsdlg(windowTitle, infoText, defaultChoice, theChoices, allowMultiple, allowCancel);
        ex1:
        var windowTitle = 'Make your choice';
        var infoText= "text above listbox,\nfor example:\nPlease choose line termination type:";
        var theChoices = {a:'ChoiceA', b:'ChoiceB', X: 'Exit'};
        var defaultChoice = 'X'; // undefined = no default choice
        var mychoice = optionsdlg(windowTitle , infoText, defaultChoice ,theChoices , false, true); //mychoice is a string
        var mychoice = optionsdlg(windowTitle , infoText, defaultChoice ,theChoices , true, true); //mychoice is an array of strings
        ex2:
        var theChoices = {"DOS","UNIX","MAC"};
        var defaultChoice = -1; // -1 or undefined = no default choice
        var mychoice = optionsdlg(windowTitle , infoText, defaultChoice ,theChoices , false, true); //mychoice is an integer
        var mychoice = optionsdlg(windowTitle , infoText, defaultChoice ,theChoices , true, true); //mychoice is an array of integers


        I think this would give script writers an extra level of interaction with their users. It's somewhat like being given the power of creating a userform from within Javascript (albeit with limited functionality). I think this complements alert(), confirm(), and prompt() nicely.

          May 11, 2011#4

          Yes, actually a list box on a form would be sufficient. The call to the function must include a "multiselect" boolean parameter. The UE custom window could look like this:

          Code: Select all

          ---------------------------------------------------
          |Title                                           X|
          ---------------------------------------------------
          |   -------------------------------------------   |
          |   | listbox with the options in it          |   |
          |   |                                         |   |
          |   |                                         |   |
          |   |                                         |   |
          |   |                                         |   |
          |   |                                         |   |
          |   -------------------------------------------   |
          |                                                 |
          |   info text                                     |
          |                                                 |
          |                                                 |
          |        CANCELBUTTON          OKAYBUTTON         |
          ---------------------------------------------------
          
          Or an approximate facsimile thereof.

          46
          Basic UserBasic User
          46

            Jun 19, 2013#5

            I know this topic was open long time ago, but it's exactly what I'm looking for.
            Is there any news on that option dialog implementation?

            Regards,
            palou.

            6,680583
            Grand MasterGrand Master
            6,680583

              Jun 20, 2013#6

              IDM has not implemented yet a command which opens a dialog to choose one or more options from a list.

              And it looks like nobody has written a small tool which could be executed via a user tool to interact with an UltraEdit script.

              Edited on 2013-08-17:

              After some discussions palou and rhapdog started both a project to code such an options dialog tool in June 2013.

              The tool written by rhapdog was completed finally and is now public available as it can be read below.

              2362
              MasterMaster
              2362

                Aug 16, 2013#7

                The tool to handle this has been completed, to the best of my testing. Mofi may find further issues which may still be worked on, or someone else may notice an issue that needs addressing, but the tool seems to be ready for release.

                Get it at http://www.danielwmoore.com/extras/inde ... ;down=1008

                Be sure to read the help file before using.

                1581
                Power UserPower User
                1581

                  Mar 23, 2017#8

                  Now, 4 years later, not yet integrated in UE??? :x
                  UE 26.20.0.74 German / Win 10 x 64 Pro

                  6,680583
                  Grand MasterGrand Master
                  6,680583

                    Mar 24, 2017#9

                    Peter, which features are added or which enhancements are made depend on what users request. So for getting your question answered, you would need to ask IDM support how many users requested a list box customizable by parameters for usage from within UltraEdit scripts (or not very likely UltraEdit macros). I helped rhapdog on development of this user tool and he made really a great job. It's an awesome tool, but I don't have any need of it for myself. For that reason I have also never requested a built-in customizable list box with an email to IDM support.
                    Best regards from an UC/UE/UES for Windows user from Austria

                    1581
                    Power UserPower User
                    1581

                      Mar 24, 2017#10

                      Mofi wrote:...requested a built-in customizable list box with an email to IDM support.
                      I just sent a mail. Let's wait and see ...


                      Edit: Answer from IDM
                      Thank you for your message. I agree that this would be a nice addition to scripting. I have logged your request in our internal record for this enhancement, and we might add it in a future release.

                      Thanks,
                      There are chances for implementation ...
                      UE 26.20.0.74 German / Win 10 x 64 Pro