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

Re: [Clip] Integer compares

Expand Messages
  • hsavage
    ... Edmenard, To make your clip operate as you expect all you need do is delete the word then from the last line. It will THEN count to whatever you set it
    Message 1 of 7 , Aug 6, 2002
    • 0 Attachment
      > edmenard wrote:
      >
      > Hello all. I've gone back a ways in the messages and haven't seen
      > anything similar to my problem. The following clip:
      >
      > H="Test int"
      >
      > ^!set %intgr%=0
      > :loop
      > ^!inc %intgr%
      > ^!prompt ^%intgr
      > ^!if ^%intgr% < 9 then loop
      >
      > Should run to 9 and quit. It does not, but continues to run beyond 9.
      > If you change 9 to 8 or lower, it works properly. If you change 9
      > to, say 30, it runs to 3 (first digit of 30) and terminates.
      >
      > Any thoughts?
      >

      Edmenard,

      To make your clip operate as you expect all you need do is delete the
      word 'then' from the last line.

      It will THEN count to whatever you set it for. Variables should be
      enclosed on both ends with % percent symbols. In your prompt line you
      are missing the second percent sign.


      H="Test int"
      ^!set %intgr%=0
      :loop
      ^!inc %intgr%
      ^!prompt ^%intgr%
      ^!if ^%intgr% < 11 loop


      hrs
    • Alan C.
      Hi All, Oh, I misread the original post. All I did was remove the then (not supposed to be there) ^!if ^%intgr%
      Message 2 of 7 , Aug 6, 2002
      • 0 Attachment
        Hi All,

        Oh, I misread the original post.

        All I did was remove the then (not supposed to be there)

        ^!if ^%intgr% < 9 then loop

        ^!if ^%intgr% < 9 loop

        And, on my machine the posted clip went to 9 and stopped.

        my misread made me think the issue was: why does it not stop at 8? so i reordered the clip, making it stop at 8.

        So I'm good at complicating things! Apologies :-)


        >Can't the problem be solved just by closing up the spaces in the ^!If
        >line?

        >^!if ^%intgr%<9 then loop

        ^!if ^%intgr% < 9 loop
        ^!if ^%intgr%<9 loop

        Either of the above two produces exactly the same result on my machine.

        Unless I have it wrong, I learned it from Jody's ClipClass that I always write those sorts of things like the 1st one above with spaces in them. I'm not certain if one style is preferred over the other but I somehow felt that with spaces is more appropriate, since, after all, each of those items is a parameter that can be used with the ^!If command.

        --
        "We can only approach reality." -- Scott Peck
        Later. Alan.
      • edmenard
        ... beyond 9. ... Thanks to all who responded. Removing the then completely fixed the trouble. There is no then in the documentation for the if , just
        Message 3 of 7 , Aug 6, 2002
        • 0 Attachment
          --- In ntb-clips@y..., hsavage <hsavage@p...> wrote:
          > > edmenard wrote:
          > >
          > > Hello all. I've gone back a ways in the messages and haven't seen
          > > anything similar to my problem. The following clip:
          > >
          > > H="Test int"
          > >
          > > ^!set %intgr%=0
          > > :loop
          > > ^!inc %intgr%
          > > ^!prompt ^%intgr
          > > ^!if ^%intgr% < 9 then loop
          > >
          > > Should run to 9 and quit. It does not, but continues to run
          beyond 9.
          > > If you change 9 to 8 or lower, it works properly. If you change 9
          > > to, say 30, it runs to 3 (first digit of 30) and terminates.
          > >
          > > Any thoughts?
          > >
          >
          > Edmenard,
          >
          > To make your clip operate as you expect all you need do is delete the
          > word 'then' from the last line.
          >
          > It will THEN count to whatever you set it for. Variables should be
          > enclosed on both ends with % percent symbols. In your prompt line you
          > are missing the second percent sign.
          >
          >
          > H="Test int"
          > ^!set %intgr%=0
          > :loop
          > ^!inc %intgr%
          > ^!prompt ^%intgr%
          > ^!if ^%intgr% < 11 loop
          >
          >
          > hrs

          Thanks to all who responded. Removing the "then" completely fixed the
          trouble. There is no "then" in the documentation for the "if", just
          too many years of programming too many different things. Seemed like
          there should have been "then" and my fingers/brain inserted it.

          The missing %'s for %intgr% was a typo when I prepared this example
          (from a larger project). Oddly, it does not seem to cause a problem.

          Thanks again!
        • hsavage
          ... Edmenard, True, the missing percent doesn t seem to make a difference in this case, but the protocol calls for them and in a more complex script it may
          Message 4 of 7 , Aug 6, 2002
          • 0 Attachment
            > edmenard wrote:

            > ^!if ^%intgr% < 11 loop
            >
            > hrs
            >
            > Thanks to all who responded. Removing the "then" completely fixed the
            > trouble. There is no "then" in the documentation for the "if", just
            > too many years of programming too many different things. Seemed like
            > there should have been "then" and my fingers/brain inserted it.
            >
            > The missing %'s for %intgr% was a typo when I prepared this example
            > (from a larger project). Oddly, it does not seem to cause a problem.
            >
            > Thanks again!

            Edmenard,

            True, the missing percent doesn't seem to make a difference in this
            case, but the protocol calls for them and in a more complex script it
            may produce unexplained results.

            hrs
          Your message has been successfully submitted and would be delivered to recipients shortly.