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

Something need before calling Clip??

Expand Messages
  • Wren McMains
    Hi all, HAPPY NEW YEAR! You ve been lucky, it s been a long time since you ve heard from me ... I ve been having trouble with a Clip that use to work
    Message 1 of 7 , Jan 3, 2001
      Hi all,

      HAPPY NEW YEAR! You've been lucky, it's been
      a long time since you've heard from me ...

      I've been having trouble with a Clip that use
      to work (probably before full regular expressions
      were introduced) but now causes trouble when
      executing another clip from within. The problem
      is the InsertText commands in the "Add Lines Here"
      clip overwrite each other. (If the "Add Lines Here"
      clip is executed manually right where the first one
      leaves the cursor after the search for "<body", it
      works fine.)

      Is there something I need to add before calling the
      clip, or is there a bug here somewhere? (Had this
      problem in 4.82 and it's still happening in 4.83.)

      My input is a text file that I wanted to convert
      to HTML and make capitalized words at the beginning
      of paragraphs BOLD if they were followed by a colon.

      This is a simplified version of a clip that use to work,
      but now the lines of the clip subroutine overwrite
      each other -- behavior seems to be that text is
      still selected while the sub-clip is running -- I
      first tried adding ^!Select 0 commands in the
      sub-clip, but I had to add them after every InsertText
      and the lines then went backwards (maybe I could have also
      added Jumps.) But, since the real sub-clip had dozens of
      ^!InsertText commands, adding selects and jumps after
      each was more than a little painful.

      The good news is that full regular expressions
      provide the power I needed originally to do this
      without the loop, so that's the work-around.

      -Wren

      ==== Input file ====

      TOPIC 1: this is body text.

      "TOPIC 2": more text follows.

      "TOPIC 10": more text follows.

      ==== End of Input ====

      ==== OLD CLIPS WHERE THE "Add Lines Here" FAILS ====

      H="Convert and Add Lines after <BODY>"
      ^!ToolBar "Document to HTML"
      ^!SetCursor 1:1
      :doTITLES
      ^!Find "<P>[A-Z.\" 0-9]*:" TRS
      ^!IfError doneTITLES
      ^!InsertHtml <B>^&</B>
      ^!Jump LINE_END
      ^!GoTo doTITLES
      :doneTITLES
      ^!SetCursor 1:1
      ^!Find "<body" IS
      ^!IfError noBody
      ^!Jump LINE_END
      ^!Select 0
      ^!Clip "Add Lines Here"
      ^!GoTo END
      :noBody
      ^!Prompt No BODY tag on page.

      H="Add Lines Here"
      ^!SetPasteIndent Off
      ^!InsertText ^pLine 1^p
      ^!InsertText Line 2^p
      ^!InsertText Line 3^p

      ==== END OF OLD CLIPS ====

      ==== WORKAROUND ====

      H="Convert without Loop"
      ^!ToolBar "Document to HTML"
      ^!Replace "<P>{[A-Z.\" 0-9]*:}" >> "<P><B>\1</B>" WATRS
      ^!SetCursor 1:1
      ^!Find "<body" IS
      ^!IfError noBody
      ^!Jump LINE_END
      ^!Select 0
      ^!Clip "Add Lines Here"
      ^!GoTo END
      :noBody
      ^!Prompt No BODY tag on page.

      H="Add Lines Here"
      ^!SetPasteIndent Off
      ^!InsertText ^pLine 1^p
      ^!InsertText Line 2^p
      ^!InsertText Line 3^p

      ==== END OF WORKAROUND ====
    • Alan
      Hi Wren, ... My NTP 4.83 I experimented . . I just ran the following clip code, ran it on an .htm current doc file even without using the called clip ie
      Message 2 of 7 , Jan 3, 2001
        Hi Wren,

        >Is there something I need to add before calling the
        >clip, or is there a bug here somewhere? (Had this
        >problem in 4.82 and it's still happening in 4.83.)

        My NTP 4.83 I experimented . . I just ran the following clip code, ran
        it on an .htm current doc file

        even without using the called clip ie with insertext lines in the below
        clip code, they overwrote each other, didn't work, until . . .

        but then

        There were two ways that I could get it to work. 1. use the long line
        whereby three lines are inserted using only one InserText command
        (currently commented/remarked out). 2. Use ^!Select 0 after an InsertText

        My findings indicated that the first inserttext comes along and when it is
        done it leaves selected. then the next inserttext comes along and inserts
        not where the cursor is at but inserts into the selection (selected area)
        instead (thus overwrites)

        yes, as you stated, all by itself in the separate clip it worked. but, as
        follows, it does not even like (work with) a goto a label (unless utilize
        either a number 1 or 2 method as above whereby I got it to work).

        ;^!ToolBar "Document to HTML"
        ;^!SetCursor 1:1
        :doTITLES
        ;^!Find "<P>[A-Z.\" 0-9]*:" TRS
        ^!Goto doneTITLES
        ^!IfError doneTITLES
        ^!InsertHtml <B>^&</B>
        ^!Jump LINE_END
        ^!GoTo doTITLES
        :doneTITLES
        ;^!SetCursor 1:1
        ;^!Find "<body" IS
        ;^!IfError noBody
        ;^!Jump LINE_END
        ;^!Select 0
        ;^!Delay 20
        ;^!Clip "Add Lines Here"
        ^!SetPasteIndent Off
        ;^!InsertText ^%nl%Line 1^%nl%Line 2^%nl%Line 3^%nl%
        ^!InsertText ^%nl%Line 1
        ^!Select 0
        ^!Delay 10
        ^!InsertText Line 2^%nl%
        ^!Delay 10
        ^!InsertText Line 3^%nl%
        ^!GoTo END
        :noBody
        ^!Prompt No BODY tag on page.
        ;-------<end of clip code<<

        Regards. Alan.
      • Wren McMains
        Hi Alan, ... I agree, that s exactly what it seems to be doing. ... What I don t understand is what there is about the loop which causes this behavior. If you
        Message 3 of 7 , Jan 3, 2001
          Hi Alan,

          > My findings indicated that the first inserttext comes along and when it is
          > done it leaves selected. then the next inserttext comes along and inserts
          > not where the cursor is at but inserts into the selection (selected area)
          > instead (thus overwrites)

          I agree, that's exactly what it seems to be doing.

          > yes, as you stated, all by itself in the separate clip it worked. but, as
          > follows, it does not even like (work with) a goto a label (unless utilize
          > either a number 1 or 2 method as above whereby I got it to work).

          What I don't understand is what there is about the loop which
          causes this behavior. If you don't include the loop, or you call
          the sub-clip manually it works fine. It seems to me that something
          is wrong with this picture.

          -Wren
        • Jody
          Hi Wren and Alan, ... It is suppose to behave like that. ... ^!InsertText and ^!InsertHTML act the same way when use ^& . Inserted text remains selected when
          Message 4 of 7 , Jan 3, 2001
            Hi Wren and Alan,

            >Is there something I need to add before calling the clip, or is
            >there a bug here somewhere? (Had this problem in 4.82 and it's
            >still happening in 4.83.)

            It is suppose to behave like that.

            >^!InsertHtml <B>^&</B>

            ^!InsertText and ^!InsertHTML act the same way when use "^&".

            "Inserted text remains selected when the ^& token is used..."
            As you found out the ^!Jump Line_End works for you. I use
            ^!Jump Select_End myself in cases like that.

            ^!InsertText Any text with tokens (^p/^t)
            Inserts the text following the command into the document. Since
            the text must hold on the same line as the command, you will have
            to use the ^p token to indicate line breaks. Since version 4.8,
            this command is sensitive to the "Indent on Paste" setting in the
            Options dialog box on the Clipbook tab. Inserted text remains
            selected when the ^& token is used to add text to the criteria.
            You can precede it with the command

            ^!SetPasteIndent Off
            to make it ignore the indent setting.

            ^!InsertHtml Any text with tokens (^p/^t) (added in v4.8)
            Similar to ^!InsertText command, but...

            Now, from the old days. sometimes, ^& causes problems. A lot of
            it has been worked out, but...

            You have some choices.

            Don't use ^!InsertHTML Not really an alternative, but an option. <g>
            Insert your text (line 1-n) first, then run the bold loop.
            Instead of using ^&, use ^$GetSelection$ <--- from the old days :)
            Another trick from times past is to set the code up in a Clip:

            ^!Find "<P>[A-Z.\" 0-9]*:" TRSI
            ^!IfError doneTITLES
            ^!Clip "Code"
            ^!InsertHtml <B>^%Code%</B>

            H=Code
            ^&

            I cannot really tell you why the text gets selected in the sub-
            routine - bad memory and I seldom use ^&. (I'm a ^$GetSelection$
            kind of guy out of habit;) My guess is it is something to do
            with the ^& being process first though, but I don't know why it
            is carried to the sub. I will mention it on the NextRelease list
            since we are beta testing 4.84b1 - perhaps it is a combination of
            the test staying selected since 4.8 with ^& and it being
            processed first - maybe some tweaking can be done. From Help:

            Parsing and evaluation sequence

            A. Whole Clip

            1. Comments removed
            2. Date fields evaluated ^[...^] (old format)
            3. Text selection inserted if ^& found
            4. ^!CONTINUE command executed if on first line
            5. Clip wizard based on ^?[...] fields displayed
            6. Mathematical fields evaluated ^$[...] (old format)

            B. Line by line

            1. Variables resolved (from right to left)
            2. Document name using ^*, ^**, ^#, ^## codes resolved
            3. Functions resolved (from right to left)
            4. Clip wizard based on ^?{...} fields in line displayed
            5. Clip Command executed

            Happy Clip'n!
            Jody

            http://www.notetab.net

            Subscribe, UnSubscribe, Options
            mailto:Ntb-Clips-Subscribe@...
            mailto:Ntb-Clips-UnSubscribe@...
            http://www.egroups.com/group/ntb-clips
          • Jody
            Hi Wren and Alan, and Eric, OK, here s the answer. The ^& says to keep text selected for *all* ^!Insert commands regardless of where they are, so, just use a
            Message 5 of 7 , Jan 3, 2001
              Hi Wren and Alan, and Eric,

              OK, here's the answer. The ^& says to keep text selected for
              *all* ^!Insert commands regardless of where they are, so, just
              use a called Clip or ^$GetSelection$ for cases like that. Wren,
              something you may have missed also that changed is we can now
              copy clip code from other apps and in NoteTab without it being
              executed. Due to that we lost some backwards capability and
              perhaps had to redo some Clips. See WhatsNew.txt

              H=KeepSel
              ^!InsertHTML line -1
              ^!Prompt 1
              ^!InsertText Line 1
              ^!Prompt 2
              ^!Insert ^&Line 2
              ^!Prompt 3
              ^!Insert Line 3
              ^!Clip Me

              H=Me
              ^!Insert Line 4

              H=Grin
              ^!InsertHTML <^&>
              ^!Prompt 1
              ^!InsertText <^&>
              ^!Prompt 2

              nite, I hope...

              >^!InsertText Any text with tokens (^p/^t)
              >Inserted text remains
              >selected when the ^& token is used to add text to the criteria.
              >You can precede it with the command
              >
              >^!InsertHtml Any text with tokens (^p/^t) (added in v4.8)
              >Similar to ^!InsertText command, but...


              Happy Clip'n!
              Jody

              http://www.notetab.net

              Subscribe, UnSubscribe, Options
              mailto:Ntb-Clips-Subscribe@...
              mailto:Ntb-Clips-UnSubscribe@...
              http://www.egroups.com/group/ntb-clips
            • Wren McMains
              Hi Jody (and Eric), Thanks for the info, at least now I understand it s the ^& that causes the trouble. I still think it s a bug that ^& causes future text
              Message 6 of 7 , Jan 4, 2001
                Hi Jody (and Eric),

                Thanks for the info, at least now I understand it's the ^&
                that causes the trouble.

                I still think it's a bug that ^& causes future text inserted
                in sub-clips to be selected, even after any selection is
                removed. But you're right, it seems like ^$GetSelection$
                would get around the problem until ^& is fixed.

                Thanks again,
                -Wren
              • Jody
                Hi Wren, ... It is not just future, but all Insert type commands before, after or in a called Clip which I demonstrated in the Clip I sent the list. (Did you
                Message 7 of 7 , Jan 4, 2001
                  Hi Wren,

                  >I still think it's a bug that ^& causes future text inserted in
                  >sub-clips to be selected, even after any selection is removed.
                  >But you're right, it seems like ^$GetSelection$ would get around
                  >the problem until ^& is fixed.

                  It is not just future, but all Insert type commands before, after
                  or in a called Clip which I demonstrated in the Clip I sent the
                  list. (Did you try the H=Grin Clip? ;)

                  Wether a bug or not -I cannot say for sure, but I think not, at
                  this point in time I personally would not try to improve it
                  anymore since there are at least two other ways to make it work.
                  Maybe Eric will try to improve it some, but we are getting to the
                  point where he is, for the very most part, just fixing bugs.

                  Time to get moving to a reader/editor geared towards programmers
                  and version five. The idea now is to leave 4.x as clean as
                  possible unlike other companies in whom I choose not to mention.
                  <g> If Eric starts making changes he has the chance of creating
                  new bugs which goes for any change like we have already seen in
                  beta #1. Additionally, we might not catch them only causing yet
                  for another maintenance release and a longer wait for the better
                  stuff to get released.

                  Happy Clip'n!
                  Jody

                  http://www.notetab.net

                  Subscribe, UnSubscribe, Options
                  mailto:Ntb-Clips-Subscribe@...
                  mailto:Ntb-Clips-UnSubscribe@...
                  http://www.egroups.com/group/ntb-clips
                Your message has been successfully submitted and would be delivered to recipients shortly.