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

Re: [Clip] Go to character

Expand Messages
  • dracorat
    Here is how far I have gotten on my previous line of thought. There is a line in what I am about to paste that I don t know the right syntax ... ^!Jump
    Message 1 of 38 , Jan 16, 2008
    View Source
    • 0 Attachment
      Here is how far I have gotten on my previous line of thought. There is
      a line in what I am about to paste that I don't know the right syntax
      for. I'm going to start poking around clip help to try to find it:

      :Begin
      ^!Jump Doc_Start
      :GetPosition
      ;prompt for user input
      ^!Set %position%=^?{Character Count}
      ;subtract one from position as we want to be before
      ;that character number presumably
      ^!Set %position%="^$Calc(^%position%-1)$"


      :VerifyDocLength
      ;calculate characters in document
      ;first get total characters
      ^!Set %characters%="^$Calc(^$GetTextSize$-(^$GetLineCount$)+1)$"
      ^!If "^%position%" > "^%characters%" Next ELSE MoveCursor
      ;give an error if we selected a cursor position that is too high
      ;next line is long
      ^!Info [C]Your Selection if Beyond the End of the Document. There are
      only ^%characters% characters in this document.
      ;prior line is long
      ^!Goto Terminus


      :MoveCursor
      ;Advance the position by one
      ^!MoveCursor +1
      ;Decrement Position Cursor
      ^!Set %position%="^$Calc(position%-1)$"
      ;Need clarification RE: Next Line
      ^!If "^$GetChar$" = "^%LF%" MoveCursor
      ;If we are at 0 on the position, we are there
      ^!If "^%position%" = "0" Terminus ELSE MoveCursor

      :Terminus
      ^!end

      --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@...> wrote:
      >
      > (Hope I'm not being spammy)
      >
      > OK, so the crlf-inclusive version of this script, using your previous
      > code, was pretty easy to figure out.
      >
      > What I actually need is for CRLF to be counted as one character (the
      > internal compiler condenses them to only \r instead of \r\n). (A`la
      > Unix style) Or you could say, ignoring all LFs - so I am thinking the
      > right way is to keep doing the move-cursor +1, but if next character
      > is \n, move again.
      >
      > Moving where we are OK with counting CRLFs looks like this (by
      > dissecting your code):
      >
      > ; whacked at by don at htmlfixit dot com
      > ; clip to move cursor to position x in a document
      >
      >
      > :Begin
      > ^!Jump Doc_Start
      > :GetPosition
      > ;prompt for user input
      > ^!Set %position%=^?{Character Count}
      > ;subtract one from position as we want to be before
      > ;that character number presumably
      > ^!Set %position%="^$Calc(^%position%-1)$"
      >
      > ^!MoveCursor +^%position%
      >
      > Thus, Im thinking it might be easy to extrapolate from there. Stand By!
      >
      > --Keith
      >
      > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:
      > >
      > > (My messages are moderated atm so there's a small possibility they
      > > might come through out of order)
      > > Reply 2:
      > >
      > > I just did some testing and it appears that moving from one "line" to
      > > the next artificially inflates the position counter. Allow me to
      > explain:
      > >
      > > ABC
      > > DEF
      > > GHI
      > >
      > > Using that as a test document, position 1 moves the cursor before "A"
      > > as I expect. 3 goes before "C", also as I expect.
      > >
      > > 4 and 5 would be the CR and LF characters, so the fact they both go to
      > > the end of the first line doesn't cause me concern. But when I enter
      > > "6", the cursor moves before the "F" instead of before the "D". "7"
      > > goes to the end of that line, but should logically be before the "E".
      > >
      > > I am reading the code now to see if I can figure out what is going on.
      > >
      > > --Keith
      > >
      > > --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@> wrote:
      > > >
      > > > The following line (between the long line messages) did wrap in my
      > > email
      > > > so you need to put it back on one line
      > > > > ;next line is long
      > > > > ^!Info [C]Your Selection if Beyond the End of the Document. There
      > > are
      > > > > only ^%characters% characters in this document.
      > > > > ;prior line is long
      > > >
      > > > In the following line I don't think I should really use the
      colon in
      > > > :MoveCursor. It doesn't really hurt anything but without the
      > colon is
      > > > probably preferred.
      > > > > ^!If "^%position%" = "0" end ELSE :MoveCursor
      > > >
      > >
      >
    • dracorat
      Actually, what I m saying is if you were to tab to another program, then screen updating turns back on. That s the part that seems strange to me. --Keith ...
      Message 38 of 38 , Jan 28, 2008
      View Source
      • 0 Attachment
        Actually, what I'm saying is if you were to tab to another program,
        then screen updating turns back on. That's the part that seems strange
        to me.

        --Keith

        --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@...> wrote:

        > I know that screen updating resumes when a clip ends, even if not
        > explicitly set back on. But the screen also updates when prompts and
        > clip wizards are displayed. Sometimes turning screen updating off
        and on
        > at strategic points in the clip just make it look nicer, other times
        > keeping it off speeds thing up quite a lot.
        >
        > Have fun,
        > Sheri
        >
        > PS, if you want to use disk search to search to the very end of a unix
        > file, you can run this regex pattern:
        > (*ANYCRLF)\z
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.