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

Index of cursor within document

Expand Messages
  • Jamal Mazrui
    I know I can get the position of the cursor within the current row, and the position of this row within the document, but is there a way to get the position of
    Message 1 of 3 , May 9, 2005
    • 0 Attachment
      I know I can get the position of the cursor within the current row, and
      the position of this row within the document, but is there a way to get
      the position of the cursor within the document? For example, if the
      document has 100 lines of varying lengths, and the cursor is on column
      10 of row 20, how can I know where it is within an index of the total
      number of characters in the document? I know I could iterate through
      the document and count by brute force, but I wonder if there is a more
      efficient way.

      Jamal
    • Hugo Paulissen
      ... and ... get ... Jamal, If you select everything from the cursor to the beginning of the file you can use ^$GetSelSize$ or ^$StrSize(^$GetSelection$)$...
      Message 2 of 3 , May 9, 2005
      • 0 Attachment
        "Jamal Mazrui" <Jamal.Mazrui@f...> wrote:

        > I know I can get the position of the cursor within the current row,
        and
        > the position of this row within the document, but is there a way to
        get
        > the position of the cursor within the document?


        Jamal,

        If you select everything from the cursor to the beginning of the file
        you can use ^$GetSelSize$ or ^$StrSize(^$GetSelection$)$...

        ^!SelectTo 1:1
        ^!INFO ^$GetSelSize$/^$GetTextSize$

        Hugo
      • Larry Hamilton
        James, ^!SetCursor 1:1 sets the cursor at the first character in the file. ^!SelectTo ^$GetRow$:40 will select 40 columns of text in the row the cursor is.
        Message 3 of 3 , May 9, 2005
        • 0 Attachment
          James,

          ^!SetCursor 1:1 sets the cursor at the first character in the file.

          ^!SelectTo ^$GetRow$:40 will select 40 columns of text in the row the
          cursor is.

          ^!Set %position% = ^$GetRow$:$^GetCol$ will make position the value of
          the Row and column of the cursor.

          To know where this is within an index of characters would require that
          you read in each character into an array. There are multiple ways to do
          that. Unless you already know how many characters there are in a file, I
          do not know of another way to do it. I know there is a word count on the
          menu, but that is not what I believe you are asking.

          Well, I have to go, I did something to my back earlier and cannot sit
          here any longer. I hope the others can give you more exact advice.

          Larry Hamilton
          Kairos Computer Solutions
          http://www.kairoscomputers.com/
          Sales Affiliate for Grisoft Anti-Virus

          Jamal Mazrui wrote:
          > I know I can get the position of the cursor within the current row, and
          > the position of this row within the document, but is there a way to get
          > the position of the cursor within the document? For example, if the
          > document has 100 lines of varying lengths, and the cursor is on column
          > 10 of row 20, how can I know where it is within an index of the total
          > number of characters in the document? I know I could iterate through
          > the document and count by brute force, but I wonder if there is a more
          > efficient way.
          >
          > Jamal
          >
          >
          >
          > Fookes Software: http://www.fookes.us, http://www.fookes.com
          > Fookes Software Mailing Lists: http://www.fookes.us/maillist.htm
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.