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

Re: [Clip] Integer compares

Expand Messages
  • silvermoonwoman2001
    ... beyond 9. Can t the problem be solved just by closing up the spaces in the ^!If line? ^!if ^%intgr%
    Message 1 of 7 , Aug 6, 2002
    • 0 Attachment
      --- In ntb-clips@y..., "Alan C." <acumming@c...> wrote:
      > Hello,
      >
      > >^!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.

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

      ^!if ^%intgr%<9 then loop

      >
      > 2 slightly different solutions next. note where prompt line is
      located.
      >
      > ^!set %intgr%=0
      > :loop
      > ^!prompt ^%intgr
      > ^!inc %intgr%
      > ^!if ^%intgr% < 9 loop
      >
      > ; ----------------------
      >
      > ^!set %intgr%=0
      > :loop
      > ^!inc %intgr%
      > ^!if ^%intgr% => 9 exitloop
      > ^!prompt ^%intgr
      > ^!Goto loop
      > :exitloop
      >
      >
      > >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.
      >
      > yes this has come up before. but it been a while. Inc strips
      zeroes so next is 3 clips different ways to accomodate for what Inc
      does.
      >
      > next is 3 clips. Only the top clip, Jody's is active the bottom 2
      are commented so as to not work (hope Jody doesn't mind). the 2nd or
      3rd clip might be one I wrote.
      >
      > H="inc with leading zeros"
      > ; Last updated 01-27-2002, Sojourner@S..., jody
      > ; http://www.notetab.net
      >
      > ; adds leading zeros each loop & formats right
      > ; justified x # (3 or 4 0's or spaces)
      > ^!Set %Num%=^?[Enter start count=975]
      > ^!Toolbar New Document
      > :Loop
      > ; ^!InsertText ^$StrCopyRight("00^%Num%";3)$^p
      > ^!InsertText ^$StrCopyRight(" ^%Num%";4)$^p
      > ^!Inc %Num%
      > ^!If ^%Num% > ^?[Enter end count=1012] End
      > ^!Goto Loop
      > ; ----------------------------
      > ; below alternative if used lops off the LH digit 1
      > ; ^!Set %wrdcnt%=^$Calc(^%wrdcnt%+1000)$
      > ; ^!Set %wrdcnt%=^$StrDeleteLeft(^%wrdcnt%;1)$
      > ; ----------------------------
      > ; Here is the one-line version...
      > ; ^!Set %Value%="1"
      > ; ^!Inc %Value%
      > ; ^$StrDeleteLeft(^$Calc(^%Value%+100)$;1)$
      >
      > --
      > Alan.
    • 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 2 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 3 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 4 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 5 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.