Selecting some text

Selecting some text

2
NewbieNewbie
2

    May 29, 2007#1

    I need to select some characters. To do so, I wrote the following script, though it selects all the text in the file. Who know how to copy and paste only some bytes? Thank you

    UltraEdit.selectClipboard(0);
    UltraEdit.clearClipboard();
    var i = 0;
    UltraEdit.document[1].startSelect;
    while (i < 3) {
    UltraEdit.document[1].key("RIGHT ARROW");
    i++;
    }
    UltraEdit.document[1].endSelect;
    UltraEdit.document[1].copy();
    UltraEdit.document[2].paste();

    344
    MasterMaster
    344

      May 29, 2007#2

      Errrrr, can you pls post a before and after example ?
      No clue what you want to do....
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      2
      NewbieNewbie
      2

        May 29, 2007#3

        lets say, if I have a file containing
        0123456789
        the script I posted creates a new file containing the same data
        what I expected was to have only
        012
        since I wanted to select only the first three chars

        262
        MasterMaster
        262

          May 29, 2007#4

          Edited after Mofis response below

          An alternative to moving the cursor with RIGHT ARROW and StartSelect()/EndSelect() is this trick with find and regexp for "any 3 characters":

          Code: Select all

          UltraEdit.selectClipboard(0);
          UltraEdit.clearClipboard();
          
          UltraEdit.ueReOn(); /* Let's use UE's own regexp syntax */
          UltraEdit.document[1].findReplace.regExp = true; /* we're going to find data using regular expressions */
          UltraEdit.document[1].findReplace.find("???"); /* any 3 characters */
          
          UltraEdit.document[1].copy();
          UltraEdit.document[2].paste();
          

          6,681583
          Grand MasterGrand Master
          6,681583

            May 29, 2007#5

            RIGHT ARROW is enough when selection mode is activated. But gstola has not activated the selection mode, because he as not called the function to activate it. He has only evaluated, if the function startSelect exists.

            UltraEdit.document[1].startSelect();

            and

            UltraEdit.document[1].endSelect();

            would work.

            gstola, read at forum topic UE Regular Expressions Problem the posts from Sam Hasler and me (Mofi) to understand the difference.
            Best regards from an UC/UE/UES for Windows user from Austria