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

Loop within a ^& [HIGHLIGHTED]Selection Question

Expand Messages
  • interval@csi.com
    [REPOSTED because of forgotten Subject] Dear NTrs, The clip below does only process the first line with in a selection made with ^&. Why is that ?
    Message 1 of 4 , May 7, 2001
    • 0 Attachment
      [REPOSTED because of forgotten Subject]


      Dear NTrs,

      The clip below does only process the first line with
      in a selection
      made with ^&.

      Why is that ?


      ^!ClearVariables
      ^!Set %lines%=^&
      ^!Set %x%=^$StrDelete("^%lines%";1;3)$

      ^!Append %s%=^%x%^%NL%

      :Loop
      ^!Inc %lines%
      ^!SetCursor ^%lines%:1
      ^!Select LINE
      ^!If ^%lines%<1 End
      :GotoLoop


      ^!StatusClose
      ^!TOOLBAR New Document
      ^!InsertText ^%s% ^p
      ^!Save As
      "c:\WINDOWS\Desktop\pos_1-3_^$GetDate(yyyymmddhhnnss)$.txt"



      Regards

      Hans
    • Alan C.
      Hi Hans, no loop, goes straight on down to the bottom and the select line thus leaves one line selected. No looping. If loop then :GotoLoop need be ^!Goto
      Message 2 of 4 , May 7, 2001
      • 0 Attachment
        Hi Hans,

        no loop, goes straight on down to the bottom and the select line thus
        leaves one line selected.

        No looping. If loop then :GotoLoop need be ^!Goto Loop

        also, Under your loop label I see a select line but I then don't see you
        doing anything with it (with the content of the selected line) while inside
        the loop.

        Alan.

        Dear NTrs,

        > The clip below does only process the first line with
        >in a selection
        > made with ^&.
        >
        > Why is that ?
        >
        >
        > ^!ClearVariables
        > ^!Set %lines%=^&
        > ^!Set %x%=^$StrDelete("^%lines%";1;3)$
        >
        > ^!Append %s%=^%x%^%NL%
        >
        > :Loop
        > ^!Inc %lines%
        > ^!SetCursor ^%lines%:1
        > ^!Select LINE
        > ^!If ^%lines%<1 End
        > :GotoLoop
        >
        >
        > ^!StatusClose
        > ^!TOOLBAR New Document
        > ^!InsertText ^%s% ^p
        > ^!Save As
        >"c:\WINDOWS\Desktop\pos_1-3_^$GetDate(yyyymmddhhnnss)$.txt"
      • interval@csi.com
        Hi Stephen, Hi Allen thank you very much for your help and suggestions. My Goto Loop mistake was inexcusable... still... H= stephen shans sline
        Message 3 of 4 , May 9, 2001
        • 0 Attachment
          Hi Stephen, Hi Allen

          thank you very much for your help and suggestions.
          My Goto Loop mistake was inexcusable...


          still...


          H="stephen'shans'sline"
          ^!ClearVariables
          ^!Set %linerow%=^$GetRow$

          :Loop
          ^!Set %lines%=^$GetSelection$
          ^!Set %x%=^$StrDelete("^%lines%";1;3)$
          ^!Append %s%=^%x%^%NL%
          ^!Inc %linerow%
          ^!SetCursor ^%linerow%:1
          ^!Select LINE
          ^!If ^%linerow%>=^$GetTextLineCount$ SKIP
          ^!Goto Loop

          ^!StatusClose
          ^!TOOLBAR New Document
          ^!InsertText ^%s% ^p
          ^!Save As
          "c:\WINDOWS\Desktop\delete_pos_1-3_^$GetDate(yyyymmddhhnnss)$.txt"


          ... I'm having troubles :

          with this highlighted:

          AX1STEPHEN
          BY2STEPHEN
          CZ3STEPHEN

          ...applying clip above, the result is the the following:

          STEPHEN
          BY2STEPHEN
          CZ3STEPHEN
          STEPHEN



          ...hmmm ?

          Hans
        • Alan C.
          Hi Hans, ... (an array clip code is below) To follow NoteTab s tradition, someone will have/create a third way, but until then: From text that you have
          Message 4 of 4 , May 9, 2001
          • 0 Attachment
            Hi Hans,

            >...applying clip above, the result is the the following:
            >
            >STEPHEN
            >BY2STEPHEN
            >CZ3STEPHEN
            >STEPHEN

            (an array clip code is below)

            To follow NoteTab's tradition, someone will have/create a third way, but
            until then:

            From text that you have selected, you want first three characters of each
            line stripped -> If I have a correct understanding of desired tasks for
            clip to perform then, as far as clip's needed structure/mechanics -> I see
            2 somewhat differing ways to do it -> Either 1. you need an array or else,
            instead, 2. paste your entire selection into a new doc and then "work" the
            pasted text on a "line by line" basis (can close discard that doc just
            previous to clip's end) but paste/insert its accumulated results into
            another, your keeper doc.

            This is a fun one, brought me some needed practice, gave exercise to my
            thinking cap which had been sitting over in the corner collecting dust.

            Thanks to all my teachers, Jody, Wayne, Eb, Claes, Charles, and, really,
            All members on this list, too many to mention here, there's not been a
            member that I didn't learn something from.

            Following uses an array, advances/"works" one line at a time during each
            loop. The clip worked for me when I tested it on Hans's sample text.

            ; Last edited:Wednesday, 09 May 2001
            ^!ClearVariables
            ^!Set %lines%=^$GetSelection$
            ^!SetListDelimiter ^p
            ^!SetArray %lines%=^%lines%
            ^!Set %index%=0
            :Loop
            ^!Inc %Index%
            ^!If ^%Index% > ^%lines0% wrapup
            ^!Set %x%=^$StrDelete("^%lines^%Index%%";1;3)$
            ^!Append %s%=^%x%^%NL%
            ^!Goto Loop
            :wrapup
            ^!StatusClose
            ^!TOOLBAR New Document
            ^!InsertText ^%s% ^p
            ^!Save As "c:\temp\test_pos_1-3_^$GetDate(yyyymmddhhnnss)$.txt"
            ;---<end clip code<<

            Thanks, Alan.
          Your message has been successfully submitted and would be delivered to recipients shortly.