Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] Strange behaviour of drop-down

Expand Messages
  • Axel Berger
    ... Well no, not really, it s a feature. Take Greek letters, it makes sense to be able to have both delta and Delta. I have found two mistakes in ... ^!Goto
    Message 1 of 12 , Apr 10 1:09 PM
    View Source
    • 0 Attachment
      Robert Bull wrote:
      > Have I missed something? Shouldn't the menu be insensitive to case?

      Well no, not really, it's a feature. Take Greek letters, it makes sense
      to be able to have both delta and Delta. I have found two mistakes in
      your clip:

      > But if I then hit Enter, I get the wrong result; NTP prints first
      > smiley in the list, presumably because that's the default.

      > ^!If "^%smiley%"="tongue" tongue
      > ^!If "^%smiley%"="" Quit
      ^!Goto Quit
      >
      > :Grin
      > ^!InsertText ^%SC%D

      Without that goto, whenever nothing matches, the clip will run right on
      to the first item, not the default, which in your case would have been
      the second.

      > ^!Set %smiley%=^?[smiley=Grin|_Smiley|Cool|

      Make that

      ^!Set %smiley%==^?[smiley=Grin|_Smiley|Cool|

      With the single equals sign you have an editable list. You'll notice
      that the cursor is indeed placed on the right item, but the "A" gets
      overwritten by your "a", so %smiley% won't match anything in your list.
      The double equals sign enforces a choice from the list.

      N.B: A feature I miss is one found in menus in other programs. With
      (T=L) or "==" only one letter is evaluated. If you don't want the first
      match it's nice to type the same letter again and jump to the next. This
      is especially relevant, if the list is sorted logically, not
      alphabetically.

      Axel
    • Art Kocsis
      Hello Robert, To answer your question: Yes. To see what you missed execute these commands and note the result: ^!Set %x%=A ^!If ^%x%=a ^!InsertText ^%x% =
      Message 2 of 12 , Apr 10 1:51 PM
      View Source
      • 0 Attachment
        Hello Robert,

        To answer your question: Yes.

        To see what you missed execute these commands and note the result:

        ^!Set %x%=A
        ^!If ^%x%=a ^!InsertText ^%x% = a^%nl%^%nl%
        ^!If ^%x%=A ^!InsertText ^%x% = A^%nl%^%nl%
        ^!If ^%x%<>a ^!InsertText ^%x% <> a^%nl%^%nl%
        ^!If ^%x%<>A ^!InsertText ^%x% <> A^%nl%^%nl%

        Then surround your wizard and error test with these statements:

        ^!InsertText ^%nl%^%nl%Before: %smiley% = "^%smiley%"^%nl%
        ;wizard and error test
        ^!InsertText After: %smiley% = "^%smiley%"^%nl%

        Execute your clip and follow your logic. You should easily see what is
        happening.

        Since you implied that you are learning clip programming I would offer a
        few suggestions:
        - Computers (and computer language interpreters), are logical and literal.
        they do not
        make the mental translation to equivalence that people do: "A" (hex
        value 41) is NOT
        equal to "a" (hex value 61).
        - Even though the wizard completed the "angry" entry from the "Angry" in
        the valueList,
        the input is still exactly what is in the input textbox, i.e., "angry".
        Literalness!
        - Notetab clips are different from most programming languages in that
        anything following
        the equals sign of a ^!Set statement is significant (including trailing
        blanks). You
        correctly tested for a null value by enclosing both within double quotes
        but as you can
        see the value was not null.
        - Testing user input directly for equality is iffy at best. Better to use
        clip functions to set
        both operands to upper or lower case before or within a test.
        - When faced with a seemingly intractable or "impossible" result,
        instrument your
        experiment: Add debug statements to see what actually is happening. It
        usually is
        not what you had thought.
        - Although your clips works (just not the way you thought it should) and is
        clear and
        maintainable, it is not scalable, is not generalized and is quite
        lengthy. I would suggest
        using arrays. Set one array to the valuelist in your wizard and use the
        array in the
        wizard (and use option T=L,H=10 or 20 to display multiple choices and
        restricts the
        selection to list values), create another array with the corresponding
        desired outputs.
        After the wizard completes, scan the valuelist using the input result to
        find the index of
        the user selection which will be the corresponding index of the desired
        output. This
        separates the clip logic from the clip data and makes it easily reusable.

        HTH,

        Namaste', Art


        At 04/10/2011 12:16, you wrote:
        >I've been trying to make a clipbook to help posts in the Donation
        >Coder forum, http://www.donationcoder.com/forum/index.php I have a
        >menu for smileys, mostly as practice in clipbook programming, and I've
        >hit what seems to be strange behaviour in NTB Pro.
        >
        >If I pop up the Smileys clip, and page through the drop-down with
        >arrow keys, things work properly.

        <snip>

        >Have I missed something? Shouldn't the menu be insensitive to case? I
        >have to say I wasn't completely consistent as to case when entering
        >smileys. The list of smileys and the clip follow:
      • Robert Bull
        Hello, Axel; ... AB Well no, not really, it s a feature. Take Greek letters, it makes AB sense to be able to have both delta and Delta. That s all Greek to
        Message 3 of 12 , Apr 10 2:01 PM
        View Source
        • 0 Attachment
          Hello, Axel;

          Sunday, April 10, 2011, 9:09:49 PM, you wrote:

          >> Have I missed something? Shouldn't the menu be insensitive to case?

          AB> Well no, not really, it's a feature. Take Greek letters, it makes
          AB> sense to be able to have both delta and Delta.

          That's all Greek to me :) I don't see any difference between Greek
          and English inasmuch as upper and lower case letters *mean* the same,
          if they (generally) look different. What I really meant is, most
          walk-down-the-list menus are case insensitive, so I expected this one
          to be too. I suppose the best thing to do is make everything in my
          clip lower-case as that's what I'm most likely to type.

          AB> I have found two mistakes in your clip:

          Argh. Thanks! I'm pretty inexperienced at this.

          >> But if I then hit Enter, I get the wrong result; NTP prints first
          >> smiley in the list, presumably because that's the default.

          >> ^!If "^%smiley%"="tongue" tongue
          >> ^!If "^%smiley%"="" Quit
          AB> ^!Goto Quit
          >>
          >> :Grin
          >> ^!InsertText ^%SC%D

          AB> Without that goto, whenever nothing matches, the clip will run
          AB> right on to the first item, not the default, which in your case
          AB> would have been the second.

          Do you mean "with" rather than "without?" Because it did indeed run on
          to the "Grin" which was first, not "Smiley" which was meant to be
          default.

          >> ^!Set %smiley%=^?[smiley=Grin|_Smiley|Cool|

          AB> Make that

          AB> ^!Set %smiley%==^?[smiley=Grin|_Smiley|Cool|

          AB> With the single equals sign you have an editable list. You'll notice
          AB> that the cursor is indeed placed on the right item, but the "A" gets
          AB> overwritten by your "a", so %smiley% won't match anything in your list.
          AB> The double equals sign enforces a choice from the list.

          Sigh. I should have spotted that one, as I've made the same mistake
          often enough in AWK. The latter doesn't have much error-checking,
          either (more if you use Thompson Automation's payware one).

          AB> N.B: A feature I miss is one found in menus in other programs.
          AB> With (T=L) or "==" only one letter is evaluated. If you don't want
          AB> the first match it's nice to type the same letter again and jump
          AB> to the next. This is especially relevant, if the list is sorted
          AB> logically, not alphabetically.

          You mean, if you type, say, "K", the cursor jumps to the first K and
          stays there? I agree that repeatedly pressing K should jump the
          cursor to the next item beginning with K, unless you prefer the "spell
          it out" approach, e.g. press K, E, Y or whatever sequentially.

          It doesn't help with NTP, but if you have any liking for
          "spell-it-out," you might like to look at Listary,
          http://www.listary.com/ (both free and payware versions). Its main
          function is aiding finding things in long lists, though it has useful
          favourite folder features too (think, FileBox Extender). There are
          both installer and portable versions (I'm not sure quite how
          portable). Version 3 is very new and at the time of writing the Web
          site only describes v2. V3 doesn't have regular expressions at present
          (they existed in 2, but I'm told they're disabled while the author
          improves them) and the text editing feature has been moved into a
          separate freeware. On the other hand, the favourite folders feature
          has been beefed up considerably.


          --
          Many thanks,

          Robert Bull
          mailto:barlennan@...
        • Axel Berger
          ... Not at all when used as mathematical symbols. You do, I take it, recognize the difference between D and d in normal spelling. You can t type Greek
          Message 4 of 12 , Apr 10 3:59 PM
          View Source
          • 0 Attachment
            Robert Bull wrote:
            > I don't see any difference between Greek and English inasmuch
            > as upper and lower case letters *mean* the same,

            Not at all when used as mathematical symbols. You do, I take it,
            recognize the difference between "D" and "d" in normal spelling. You
            can't type Greek letters directly on an American keyboard, so for HTML
            the unicode letters Δ and δ are coded as Δ and δ
            respectively. This was just the first example for case sensitivity in
            variables and placeholders that came to my mind.

            > Do you mean "with" rather than "without?"

            Certainly not. Coming from the top your clip looks at each ^!If in order
            and whenever the answer is no, it moves to the next line. There was not
            supposed to be a case when all the ifs were negative, but when it
            happened the code went on going to the next line and running into the
            first of your smileys. It is good practice in programming, especially
            for user input, always to provide a safe default reaction in case none
            of the expected ones fires.

            > You mean, if you type, say, "K", the cursor jumps to the first K and
            > stays there? I agree that repeatedly pressing K should jump the
            > cursor to the next item beginning with K,

            Unfortunately with this kind of list input, that's just what happens. It
            doesn't matter for alphabetically sorted lists, but some of mine are
            grouped differently.

            Axel
          • Eb
            Rbt, NoteTab is selectively case sensitive in clipnames. If more than one clip matches a key combinaation, it is case sensitive. If only one clip matches, NT
            Message 5 of 12 , Apr 11 2:38 PM
            View Source
            • 0 Attachment
              Rbt,

              NoteTab is selectively case sensitive in clipnames. If more than one clip matches a key combinaation, it is case sensitive. If only one clip matches, NT will accept either case. Try the following to demonstrate this.

              Add the following clips to any library:

              H="A"
              ^$GetCLipname$

              H="a"
              ^$GetCLipname$

              H="b"
              ^$GetCLipname$

              H="C"
              ^$GetCLipname$


              Then set the library to AutoReplace, and type the following series of characters (no quotes), slowly so you can see what happens.

              " b B c C a A "

              Since there is only one clip named 'c' or 'b', it will change case to the clipname. But there are two 'a' clips, one lower case, one upper case. NoteTab will interpret the names case sensitive.


              Cheers.


              --- In ntb-clips@yahoogroups.com, Robert Bull <barlennan@...> wrote:
              >
              > I've been trying to make a clipbook to help posts in the Donation
              > Coder forum, http://www.donationcoder.com/forum/index.php I have a
              > menu for smileys, mostly as practice in clipbook programming, and I've
              > hit what seems to be strange behaviour in NTB Pro.
              >
              > If I pop up the Smileys clip, and page through the drop-down with
              > arrow keys, things work properly.
              >
              > But I expect to be able to type the first few letters to get to the
              > target, as in most menus, then press Enter, and have the smiley
              > appear. This turns out to be case-sensitive. That is, if I'm looking
              > for the Angry smiley I'm likely to type "a, n, g" lower-case, which
              > puts the cursor on right entry. But if I then hit Enter, I get the
              > wrong result; NTP prints first smiley in the list, presumably because
              > that's the default. On the other hand if I type "A, n, g" i.e,
              > upper-case A, I get the correct result. Further, I think it only
              > "misbehaved" where there it thought something was ambiguous. Where a
              > smiley name had a unique collection of letters, e.g. "mad", it seemed
              > consistently correct.
              >
              > Have I missed something? Shouldn't the menu be insensitive to case? I
              > have to say I wasn't completely consistent as to case when entering
              > smileys. The list of smileys and the clip follow:
              >
              > ---------
              > Smileys (what I wanted NTP to enter, minus the name)
              >
              > Grin ;D
              > smiley :)
              > cool 8)
              > Wink ;)
              > sad :(
              > angry >:(
              > cheesy :D
              > tellme :tellme:
              > ohmy :o
              > huh :huh:
              > embarrassed :-[
              > thumbs down :down:
              > thumbs up :up:
              > thumbs up with smiling wink :Thmbsup:
              > Cry :'(
              > mad :mad:
              > undecided :-\
              > Kiss :-*
              > tongue :P
              > ---------
              >
              > ---------
              > Smileys - the clip
              >
              > ^!Set %smiley%=""
              > ^!Set %COLON%=:
              > ^!Set %SC%=;
              > ^!Set %smiley%=^?[smiley=Grin|_Smiley|Cool|Wink|Sad|Angry|Cheesy|tellme|ohmy|huh|embarassed|thumb down|thumbs up|thumbs up with smiling wink|Cry|mad|undecided|kiss|tongue]
              > ^!IfError Exit
              > ^!If "^%smiley%"="Grin" Grin
              > ^!If "^%smiley%"="Smiley" Smiley
              > ^!If "^%smiley%"="Cool" Cool
              > ^!If "^%smiley%"="Wink" Wink
              > ^!If "^%smiley%"="Sad" Sad
              > ^!If "^%smiley%"="Angry" Angry
              > ^!If "^%smiley%"="Cheesy" Cheesy
              > ^!If "^%smiley%"="tellme" tellme
              > ^!If "^%smiley%"="ohmy" ohmy
              > ^!If "^%smiley%"="huh" huh
              > ^!If "^%smiley%"="embarassed" embarassed
              > ^!If "^%smiley%"="thumb down" thumb_down
              > ^!If "^%smiley%"="thumbs up" thumbs_up
              > ^!If "^%smiley%"="thumbs up with smiling wink" thumbs_up_with_smiling_wink
              > ^!If "^%smiley%"="Cry" Cry
              > ^!If "^%smiley%"="mad" mad
              > ^!If "^%smiley%"="undecided" undecided
              > ^!If "^%smiley%"="kiss" kiss
              > ^!If "^%smiley%"="tongue" tongue
              > ^!If "^%smiley%"="" Quit
              >
              > :Grin
              > ^!InsertText ^%SC%D
              > ^!GoTo Quit
              >
              > :Smiley
              > ^!InsertText ^%COLON%)
              > ^!GoTo Quit
              >
              > :Cool
              > 8)
              > ^!GoTo Quit
              >
              > :Wink
              > ^!InsertText ^%SC%)
              > ^!GoTo Quit
              >
              > :Sad
              > ^!InsertText ^%COLON%(
              > ^!GoTo Quit
              >
              > :Angry
              > ^!InsertText >^%COLON%(
              > ^!GoTo Quit
              >
              > :Cheesy
              > ^!InsertText ^%COLON%D
              > ^!GoTo Quit
              >
              > :tellme
              > ^!InsertText ^%COLON%tellme^%COLON%
              > ^!GoTo Quit
              >
              > :ohmy
              > ^!InsertText ^%COLON%o
              > ^!GoTo Quit
              >
              > :huh
              > ^!InsertText ^%COLON%huh^%COLON%
              > ^!GoTo Quit
              >
              > :embarassed
              > ^!InsertText ^%COLON%-[
              > ^!GoTo Quit
              >
              > :thumb_down
              > ^!InsertText ^%COLON%down^%COLON%
              > ^!GoTo Quit
              >
              > :thumbs_up
              > ^!InsertText ^%COLON%up^%COLON%
              > ^!GoTo Quit
              >
              > :thumbs_up_with_smiling_wink
              > ^!InsertText ^%COLON%Thmbsup^%COLON%
              > ^!GoTo Quit
              >
              > :Cry
              > ^!InsertText ^%COLON%'(
              > ^!GoTo Quit
              >
              > :mad
              > ^!InsertText ^%COLON%mad^%COLON%
              > ^!GoTo Quit
              >
              > :undecided
              > ^!InsertText ^%COLON%-\
              > ^!GoTo Quit
              >
              > :kiss
              > ^!InsertText ^%COLON%-*
              > ^!GoTo Quit
              >
              > :tongue
              > ^!InsertText ^%COLON%P
              > ^!GoTo Quit
              >
              > :Quit
              > ---------
              >
              > --
              > TIA,
              >
              > Robert Bull
              > mailto:barlennan@...
              >
            • Robert Bull
              On Sunday, April 10, 2011, 9:51:38 PM, Art Kocsis wrote: AK - Testing user input directly for equality is iffy at best. Better AK to use clip functions to
              Message 6 of 12 , Apr 13 3:31 AM
              View Source
              • 0 Attachment
                On Sunday, April 10, 2011, 9:51:38 PM, Art Kocsis wrote:

                AK> - Testing user input directly for equality is iffy at best. Better
                AK> to use clip functions to set both operands to upper or lower case
                AK> before or within a test.

                Sounds a good idea, given that NTP's menus don't behave as regular
                Windows drop-downs do. More accurately, I suppose, NTP gives you the
                raw mechanics and you have to do the behind-the-scenes checking
                yourself. More to learn...

                AK> - Although your clips works (just not the way you thought it
                AK> should) and is clear and maintainable, it is not scalable, is not
                AK> generalized and is quite lengthy.

                Oh, I'm not a programmer! I don't have a programmer's mind :) I'll
                bodge up any combination of batch files, with batch file enhancers,
                AWK scripts and macros, that *I* can understand and have some chance
                of modifying later. I rarely needed to optimise anything, even when
                I was at work.

                In this particular case, generalisation is unnecessary. The smileys
                come up in the forum as icons, but they can't be shown in NTP as
                anything other than text. There's a limit to the number of text
                equivalents I want to remember. It might be better to use an
                alternative input system with buttons with icons on them to type the
                codes. If I could face the thought of configuring PowerPro again, that
                might be a possibility. Or Typeitin, if that does icons as well as
                text.


                --
                Thanks,

                Robert Bull
                mailto:barlennan@...
              • Robert Bull
                ... AB Certainly not. Coming from the top your clip looks at each ^!If in order AB and whenever the answer is no, it moves to the next line. There was not
                Message 7 of 12 , Apr 13 8:16 AM
                View Source
                • 0 Attachment
                  On Sunday, April 10, 2011, 11:59:09 PM, Axel Berger wrote:

                  >> Do you mean "with" rather than "without?"

                  AB> Certainly not. Coming from the top your clip looks at each ^!If in order
                  AB> and whenever the answer is no, it moves to the next line. There was not
                  AB> supposed to be a case when all the ifs were negative, but when it
                  AB> happened the code went on going to the next line and running into the
                  AB> first of your smileys. It is good practice in programming, especially

                  Ah, yes, I see what you meant now. Thanks for clarifying.


                  --
                  Regards,

                  Robert Bull
                  mailto:barlennan@...
                • Robert Bull
                  On Monday, April 11, 2011, 10:38:22 PM, Eb wrote: E NoteTab is selectively case sensitive in clipnames. If more than E one clip matches a key combinaation,
                  Message 8 of 12 , Apr 13 8:20 AM
                  View Source
                  • 0 Attachment
                    On Monday, April 11, 2011, 10:38:22 PM, Eb wrote:

                    E> NoteTab is selectively case sensitive in clipnames. If more than
                    E> one clip matches a key combinaation, it is case sensitive.

                    I'm not saying that it isn't in Help, but I didn't spot it. Actually,
                    I've found Help to be more cryptic than I'd expect from its quite
                    large size, and harder to find things in than I'd like. Hence, the
                    mailing list is a very useful resource...


                    --
                    Thanks,

                    Robert Bull
                    mailto:barlennan@...
                  • Axel Berger
                    ... True, but it makes things more complicated. Actually the NoteTab wizard offers a better solution, you can select one thing and load the variable with
                    Message 9 of 12 , Apr 13 9:21 AM
                    View Source
                    • 0 Attachment
                      Art Kocsis wrote:
                      > Although your clips works (just not the way you thought it
                      > should) and is clear and maintainable, it is not scalable, is not
                      > generalized and is quite lengthy. I would suggest using arrays.
                      > Set one array to the valuelist in your wizard and use the array in
                      > the wizard (and use option T=L,H=10 or 20 to display multiple
                      > choices and restricts the selection to list values), create
                      > another array with the corresponding desired outputs. After the
                      > wizard completes, scan the valuelist using the input result to
                      > find the index of the user selection which will be the
                      > corresponding index of the desired output. This separates the clip
                      > logic from the clip data and makes it easily reusable.

                      True, but it makes things more complicated. Actually the NoteTab wizard
                      offers a better solution, you can select one thing and load the variable
                      with another (It is very well hidden in help and I tend to foget and go
                      the ^!If way too most of the time):

                      ^!Set %smiley%=^?[smiley==Grin^=^%SC%D|_Smiley^=^%COLON%)]
                      ^!InsertText ^%smiley%

                      Axel
                    • Art Kocsis
                      Hey Axel, Complexity is relative. Indvidual tests for lists of 150+ items is not something I want to contemplate (or debug-typos), but you are right. In
                      Message 10 of 12 , Apr 13 11:21 AM
                      View Source
                      • 0 Attachment
                        Hey Axel,

                        Complexity is relative. Indvidual tests for lists of 150+ items is
                        not something I want to contemplate (or debug-typos), but you
                        are right. In general most lists are smaller and separate tests
                        work fine. As an old school programmer, I tend to like compact
                        elegant code and try to make my clips generalized so they can
                        be reused.

                        However, your suggestion to use the wizard like a Javascript
                        <options> list is much "mo' betta" than either of the above. And
                        a long valuelist can easily be generated by appending sequential
                        numbers (and separators), that the wizard will return as an index.
                        I will have to remember that one. Ah. There's the rub - remembering!

                        Namaste', Art

                        At 04/13/2011 09:21, you wrote:
                        >Art Kocsis wrote:
                        > > Although your clips works (just not the way you thought it
                        > > should) and is clear and maintainable, it is not scalable, is not
                        > > generalized and is quite lengthy. I would suggest using arrays.
                        > > Set one array to the valuelist in your wizard and use the array in
                        > > the wizard (and use option T=L,H=10 or 20 to display multiple
                        > > choices and restricts the selection to list values), create
                        > > another array with the corresponding desired outputs. After the
                        > > wizard completes, scan the valuelist using the input result to
                        > > find the index of the user selection which will be the
                        > > corresponding index of the desired output. This separates the clip
                        > > logic from the clip data and makes it easily reusable.
                        >
                        >True, but it makes things more complicated. Actually the NoteTab wizard
                        >offers a better solution, you can select one thing and load the variable
                        >with another (It is very well hidden in help and I tend to foget and go
                        >the ^!If way too most of the time):
                        >
                        >^!Set %smiley%=^?[smiley==Grin^=^%SC%D|_Smiley^=^%COLON%)]
                        >^!InsertText ^%smiley%
                        >
                        >Axel
                        >
                      • Robert Bull
                        On Wednesday, April 13, 2011, 7:21:32 PM, Art Kocsis wrote: AK I will have to remember that one. Ah. There s the rub - AK remembering! Make it an entry in an
                        Message 11 of 12 , Apr 13 2:46 PM
                        View Source
                        • 0 Attachment
                          On Wednesday, April 13, 2011, 7:21:32 PM, Art Kocsis wrote:

                          AK> I will have to remember that one. Ah. There's the rub -
                          AK> remembering!

                          Make it an entry in an NTP OTL file?

                          :) <whistles innocently>


                          --
                          Regards,

                          Robert Bull
                          mailto:barlennan@...
                        Your message has been successfully submitted and would be delivered to recipients shortly.