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

Confusing the Parser

Expand Messages
  • Wayne VanWeerthuizen
    I believe I have found some more examples of how to confuse the clip parser in NoteTab Pro 4.82. H= Example 1 - Gives Wrong Result ^!Set A= ^!Set B=
    Message 1 of 7 , Jul 30, 2000
      I believe I have found some more examples of how to confuse
      the clip parser in NoteTab Pro 4.82.

      H="Example 1 - Gives Wrong Result"
      ^!Set A=" " " " "
      ^!Set B=" " " " "
      ^!Info [L] A:[^%A%]^P B:[^%B%]
      ^!IfSame "^%A%" "^%B%" ^!Info SAME
      ^!IfDiff "^%A%" "^%B%" ^!Info DIFF


      H="Example 2 - Still Gives Wrong Result"
      ^!Set A=" " " " "
      ^!IfDiff "^%A%" "^%A%" ^!Info DIFF

      The parser fails because it converts the code above into
      something like this:

      H="Example 3 - Ambiguous"
      ^!IfSame " " " " " " " " " " ^!Info SAME
      ^!IfDiff " " " " " " " " " " ^!Info DIFF

      That is, the parser loses information the programmer had given it.
      (e.g. When plugging variables into the clip code, the parser forgets
      where they begin and end, effectively creating ambiguities that didn't
      exist in the original clip.)

      Eric has already told us that a fix for problems of this sort is
      planned for NoteTab 5.

      What I would like to know is, "What other clip commands or functions
      can trigger this sort of bug?" I would like to include a list of
      known bugs or "problematic situations" with the revised NoteTab
      Reference Outline that I am taking sooooo looong to complete. ;-)
      (Jody, rest assured I haven't forgotten about it. I just keep
      getting busy or sidetracked. Every so often I do a bit more work on
      it.)

      Again, I would like those who know of other problematic situations
      or potential "gotchas" with the clip language to submit them to
      me (or to the clips list) so I can include them in the outline.
      Thanks in advance to those who can help.
















      --
      Wayne M. VanWeerthuizen
      Homepage: http://landru.myhome.net/wayne
    • Alan Williams
      Hi experts, I need guidance on a seeming intractable problem looping through array elements. I have 22 arrays of 6 numbers, the arrays are named ba, bb ... bv
      Message 2 of 7 , Jul 31, 2000
        Hi experts, I need guidance on a seeming intractable problem looping
        through array elements.

        I have 22 arrays of 6 numbers, the arrays are named ba, bb ... bv

        I wish to check a new array of 6 numbers against all the numbers in
        the 22 arrays.

        Lets say I call the new array %check% and to check all its numbers
        against all the numbers in the first of the 22 arrays and then loop
        through the arrays I declare another 2 arrays

        ^!Set %nin%=1
        ^!Set %non%=0
        ^!Set %num%=1
        ^!SetArray %alpha%=a; b; c; d; e; f; g; h; i; j; k; l; m; n; o; p; q; r; s; t; u; v

        Then I test-

        :doloop
        ^!Inc %non%
        ^!If ^%non% > 6 nuloop
        ^!If ^%b^%alpha^%num%%^%non%%=^%check^%nin%% mtc else doloop

        The idea is to test the first number of array %ba% for a match with
        the first number of array %check%, then second number of %ba%, then
        3rd.

        If there is a match, the clip branches to label :mtc where the
        variable %match% is incremented, the variable %nin% is incremented,
        %non% is reset to 0 and all values of %ba% are tested against the
        second value of %check%

        The :nuloop branch does much the same as mtc, except it just
        increments %nin% and restarts the loop

        Both :mtc and :nuloop test for %nin% being greater than 6, in that
        case the clip branches to :reset

        It is here that the problem arises.

        :reset increments variable %num% which then should increment
        array %alpha%s index so that

        ^%b^%alpha^%num%%^%non%% =%bb1%

        And the whole process is repeated

        Now I understand that I might be trying my luck a little by wrapping
        variables in variables, however it appears to work perfectly the first
        time it is stated that way.


        However, when %num% increments, the parser loses track of the wrapped
        variables and reads ^%alpha^%num%% as the array element, in this case
        b and a % sign

        I also tried to reduce the clutter by

        ^!Set %curr%=^%alpha^%num%%, but got the same result



        My plea to the experts is this: how do I get the loop through the
        arrays.

        -----------------------------------------------------
        shortend version of my clip follows
        ------------------------------------------------------
        ^!SetArray %ba%=11; 30; 34; 41; 44; 46
        ^!SetArray %bb%=17; 25; 37; 38; 44; 46
        ^!SetArray %bc%=4; 9; 18; 19; 21; 37
        ^!SetArray %bd%=3; 5; 7; 22; 42; 44

        ^!SetArray %check%=^?{Type in numbers separated by semi-colons=}

        ^!SetArray %alpha%=a; b; c; d; e; f; g; h; i; j; k; l; m; n; o; p; q; r; s; t; u; v

        ^!Set %match%=0
        ^!Set %num%=1
        ^!Set %non%=0
        ^!Set %nin%=1

        :doloop

        ^!Inc %non%
        ^!If ^%non% > 6 nuloop
        ^!If ^%b^%alpha^%num%%^%non%%=^%check^%nin%% mtc else doloop

        :nuloop

        ^!Inc %nin%
        ^!If ^%nin% > 6 reset
        ^!Set %non%=0
        ^!Goto doloop

        :mtc
        ^!inc %match%
        ^!inc %nin%
        ^!If ^%nin% > 6 reset
        ^!GoTo doloop

        :reset
        ^!Info There were ^%match% matches in array ^%num%
        ^!If ^%num% > 22 end
        ^!inc %num%
        ^!Set %non%=0
        ^!Set %nin%=1
        ^!Goto doloop
        --------------------------------------------------
        ends clip
        --------------------------------------------------


        Best regards,
        Alan

        mailto:alwilli@...
      • Eb Guenther
        Hi Alan Williams, Right away one thing comes to mind: when you make array assignments, and there are spaces embedded in the array elements, these spaces vecome
        Message 3 of 7 , Jul 31, 2000
          Hi Alan Williams,

          Right away one thing comes to mind: when you make array assignments, and
          there are spaces embedded in the array elements, these spaces vecome part
          of the data! You should probably assign the constant data without spaces.

          ESPECIALLY if any of that data becomes part of a variable name!



          > ^!SetArray %alpha%=a; b; c; d; e; etc.

          Should be:

          > ^!SetArray %alpha%=a;b;c;d;e; etc.
        • alwilli
          Dear Eb, ... Thanks! working in effective isolation makes it easy to not see the woods for the trees. I had been working on the clip before your good advice
          Message 4 of 7 , Jul 31, 2000
            Dear Eb,
            Monday, July 31, 2000, you wrote:

            > > ^!SetArray %alpha%=a; b; c; d; e; etc.
            > Should be:
            > > ^!SetArray %alpha%=a;b;c;d;e; etc.

            Thanks! working in effective isolation makes it easy to not see the
            woods for the trees. I had been working on the clip before your good
            advice and immediately amended all array statements to exclude spaces.
            It is possible I also inadvertently corrected another syntax error
            prior to that (well I did fix some omissions I spotted). Whatever,
            after I followed your advice it works as planned so I credit you. But
            Im not finished with this clip yet, having overcome this obstacle, Im
            setting new ones. I'll try restrain calling for help until I've
            exhausted my ingenuity. For the record, the working clip (shortened to
            four arrays and altered to take that into account) follows.

            -----------------------
            begin clip
            -----------------------
            ^!SetArray %ba%=11;30;34;41;44;46
            ^!SetArray %bb%=17;25;37;38;44;46
            ^!SetArray %bc%=4;9;18;19;21;37
            ^!SetArray %bd%=3;5;7;22;42;44

            ^!SetArray %check%=^?{Type in numbers separated by semi-colons,no spaces=}

            ^!SetArray %alpha%=a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v

            ^!Set %match%=0
            ^!Set %num%=1
            ^!Set %non%=0
            ^!Set %nin%=1
            ^!Setdebug ON
            ^!Set %curr%=^%alpha^%num%%

            :doloop
            ^!Inc %non%
            ^!If ^%non%>6 nuloop
            ^!If ^%b^%curr%^%non%%=^%check^%nin%% mtc else doloop

            :nuloop
            ^!Inc %nin%
            ^!If ^%nin%>6 reset
            ^!Set %non%=0
            ^!Goto doloop

            :mtc
            ^!inc %match%
            ^!inc %nin%
            ^!If ^%nin%>6 reset
            ^!GoTo doloop

            :reset
            ^!Info There were ^%match% matches in ^%b^%curr%%
            ^!Set %match%=0
            ^!If ^%num%>4 end
            ^!inc %num%
            ^!Set %non%=0
            ^!Set %nin%=1
            ^!Set %curr%=^%alpha^%num%%
            ;^!Continue alpha letter is now ^%curr%
            ^!Goto doloop
            --------------------------
            end clip
            -------------------------





            --
            Best regards,
            Alan
            mailto:alwilli@...
          • alwilli
            Dear Eb, ... Thanks! working in effective isolation makes it easy to not see the woods for the trees. I had been working on the clip before your good advice
            Message 5 of 7 , Jul 31, 2000
              Dear Eb,
              Monday, July 31, 2000, you wrote:

              > > ^!SetArray %alpha%=a; b; c; d; e; etc.
              > Should be:
              > > ^!SetArray %alpha%=a;b;c;d;e; etc.

              Thanks! working in effective isolation makes it easy to not see the
              woods for the trees. I had been working on the clip before your good
              advice and immediately amended all array statements to exclude spaces.
              It is possible I also inadvertently corrected another syntax error
              prior to that (well I did fix some omissions I spotted). Whatever,
              after I followed your advice it works as planned so I credit you. But
              Im not finished with this clip yet, having overcome this obstacle, Im
              setting new ones. I'll try restrain calling for help until I've
              exhausted my ingenuity. For the record, the working clip (shortened to
              four arrays and altered to take that into account) follows.

              -----------------------
              begin clip
              -----------------------
              ^!SetArray %ba%=11;30;34;41;44;46
              ^!SetArray %bb%=17;25;37;38;44;46
              ^!SetArray %bc%=4;9;18;19;21;37
              ^!SetArray %bd%=3;5;7;22;42;44

              ^!SetArray %check%=^?{Type in numbers separated by semi-colons,no spaces=}

              ^!SetArray %alpha%=a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v

              ^!Set %match%=0
              ^!Set %num%=1
              ^!Set %non%=0
              ^!Set %nin%=1
              ^!Setdebug ON
              ^!Set %curr%=^%alpha^%num%%

              :doloop
              ^!Inc %non%
              ^!If ^%non%>6 nuloop
              ^!If ^%b^%curr%^%non%%=^%check^%nin%% mtc else doloop

              :nuloop
              ^!Inc %nin%
              ^!If ^%nin%>6 reset
              ^!Set %non%=0
              ^!Goto doloop

              :mtc
              ^!inc %match%
              ^!inc %nin%
              ^!If ^%nin%>6 reset
              ^!GoTo doloop

              :reset
              ^!Info There were ^%match% matches in ^%b^%curr%%
              ^!Set %match%=0
              ^!If ^%num%>4 end
              ^!inc %num%
              ^!Set %non%=0
              ^!Set %nin%=1
              ^!Set %curr%=^%alpha^%num%%
              ;^!Continue alpha letter is now ^%curr%
              ^!Goto doloop
              --------------------------
              end clip
              -------------------------





              --
              Best regards,
              Alan
              mailto:alwilli@...
            • Eb Guenther
              Hi alwilli, ... Though I m not clear what your goal is, let me make some suggestions anyway. If they don t fit into your pllans just ignore them: If your
              Message 6 of 7 , Aug 1, 2000
                Hi alwilli,

                >I'll try restrain calling for help until I've exhausted my
                >ingenuity. For the record, the working clip (shortened to
                >four arrays and altered to take that into account) follows.

                Though I'm not clear what your goal is, let me make some
                suggestions anyway. If they don't fit into your pllans just
                ignore them:

                If your %alpha% array serves only to iterate through the
                rows of arrays, you can use a letter or symbol after a number
                to keep it from being parsed as an index. For example
                change %bb% to %b_1_%, %bc% to %b_2_%, etc. Then you can
                use ^%b_^%num%_^%nom%%% directly, instead of by way of ^%curr%
                and ^%alpha%.

                If you also change %num% to %row% and %nom% to %col%, the
                above will look like ^%b_^%row%_^%col%%.


                With that you can change all uses of curr to row:
                ^%curr% --> _^%row%_
                and remove all assignments to %curr% and the entire alpha array.

                One more thing -- in the :reset section, increment %row% before
                testing it for last row.


                Good luck,

                Eb
              • Jody
                Hi Wayne ... I was starting to wonder. ;) I have been getting with a shortened version of your s where I stripped out all the Help file stuff only leaving the
                Message 7 of 7 , Aug 2, 2000
                  Hi Wayne

                  > ...the revised NoteTab Reference Outline that I am taking
                  > sooooo looong to complete. ;-) (Jody, rest assured I haven't
                  > forgotten about it.

                  I was starting to wonder. ;) I have been getting with a
                  shortened version of your's where I stripped out all the Help
                  file stuff only leaving the command/functions and added the ones
                  for 4.82.

                  I'll send you any syntax problems should I run across any.

                  Thanks!
                  Jody

                  Clean-Funnies: click and send...
                  mailto:c-f@...?subject=Subscribe
                Your message has been successfully submitted and would be delivered to recipients shortly.