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

DO loops

Expand Messages
  • Robert Bull
    Am I right in thinking that NTP s clipbook language doesn t have a FOR ... DO construct? That if you want to make a loop, you have to do something like
    Message 1 of 4 , Nov 21, 2010
      Am I right in thinking that NTP's clipbook language doesn't have a
      "FOR ... DO" construct? That if you want to make a loop, you have to
      do something like setting an end-of-loop label and a test to jump to
      it?

      --
      Thanks,

      Robert Bull
      mailto:barlennan@...
    • Don
      correct -- there are some past threads on this if you look
      Message 2 of 4 , Nov 21, 2010
        correct -- there are some past threads on this if you look

        On 11/21/2010 4:45 PM, Robert Bull wrote:
        > Am I right in thinking that NTP's clipbook language doesn't have a
        > "FOR ... DO" construct? That if you want to make a loop, you have to
        > do something like setting an end-of-loop label and a test to jump to
        > it?
        >
      • Ian at Yahoo
        I have not read the old threads, but this is what I do. I use loops regularly. I was using the pre-made one from the quick list but now I have two pre-made
        Message 3 of 4 , Nov 21, 2010
          I have not read the old threads, but this is what I do.

          I use loops regularly. I was using the pre-made one from the "quick
          list" but now I have two pre-made loops in a functions.
          Prerequisite is to set and array.
          ^!setarray %arrayA%=20;40;60;90;120

          If using loopB then set %arrayB%

          Then call the function with the name of the action clip as the parameter.
          ^$loopA(myaction)$

          This is the loop function like the one in "Quick List" with slight
          modifications. If you have imbeded loops, then you use a loopB function
          too. I have not needed more than two loops in use at one time.
          H="loopA"
          ^!Set %Indexa%=0
          ^!Set %LoopCounta%=^%arrayA0%
          ^!IfCancel End

          :LoopStarta
          ^!Inc %Indexa%
          ; The next line ends the loop after the last variable is processed
          ^!If ^%Indexa% > ^%LoopCounta% EndLoopa
          ; The next line calls the action clip line with the current value as the
          parameter.
          ^!clip "^&" ^%arrayA^%indexa%%

          ^!GoTo LoopStarta
          :EndLoopa

          H="myaction"
          ^!appendtofile "^%filename%" ^&

          It will not suit all loops but it is very useful. Keeps my code simpler
          in the main clip.

          Ian

          On 22/11/2010 8:57 AM, Don wrote:
          > correct -- there are some past threads on this if you look
          >
          > On 11/21/2010 4:45 PM, Robert Bull wrote:
          >> Am I right in thinking that NTP's clipbook language doesn't have a
          >> "FOR ... DO" construct? That if you want to make a loop, you have to
          >> do something like setting an end-of-loop label and a test to jump to
          >> it?
          >>
          >
          > ------------------------------------
          >
          > Fookes Software: http://www.fookes.com/
          > NoteTab website: http://www.notetab.com/
          > NoteTab Discussion Lists: http://www.notetab.com/groups.php
          >
          > ***
          > Yahoo! Groups Links
          >
          >
          >
          >

          Send instant messages to your online friends http://au.messenger.yahoo.com
        • Robert Bull
          Hello, Ian; Sunday, November 21, 2010, 11:41:48 PM, you wrote: IaY I have not read the old threads, but this is what I do. I didn t think to do that - Don,
          Message 4 of 4 , Nov 22, 2010
            Hello, Ian;

            Sunday, November 21, 2010, 11:41:48 PM, you wrote:

            IaY> I have not read the old threads, but this is what I do.

            I didn't think to do that - Don, thanks for the tip.

            IaY> I use loops regularly. I was using the pre-made one from the "quick
            IaY> list" but now I have two pre-made loops in a functions.
            [...]

            That's far too advanced for me ATM :) I wish I'd discovered the loop
            in the Quick List before, as it would have been most of what I needed.
            But not all, as I also had a struggle with Masked Input Fields. I use
            the Donation Coder forums at
            http://www.donationcoder.com/Forums/bb/index.php They use SMF
            software, and using either the "It's All Text!" extension in Firefox,
            or the similar (but multi-browser) feature in Listary,
            http://www.listary.com/ , I edit all but very short messages in NTP. I
            wanted a clip to set the SMF code for a bulleted list of any length up
            to 99. That's a lot more than is normally sensible, but I couldn't
            immediately see how to restrict the maximum number in an NTP input
            field, not that it really matters. The clip below is cobbled together
            from the Help file, augmented by a bit of searching in the NoteTab
            Clips forum:

            ------------------
            ^!Set %elements%=^?[(M="09;0; ")Number of items]
            ^!IfError Exit
            ^!If ^%elements%=0 Quit
            [list]

            ^!Set %num%=0
            :StartLoop
            [li] [/li]

            ^!Inc %num%
            ^!If ^%num%>=^%elements% EndLoop ELSE StartLoop
            :EndLoop
            [/list]

            :Quit
            ------------------

            For an input value of 3, it generates this:

            ------------------
            [list]
            [li] [/li]
            [li] [/li]
            [li] [/li]
            [/list]
            ------------------

            Have I missed anything I should have included, particularly regarding
            error checking?


            --
            Thanks,

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