Selecting some text

Help with writing and running scripts

Selecting some text

Postby gstola » Mon May 28, 2007 7:41 pm

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();
User avatar
gstola
Newbie
 
Posts: 2
Joined: Sun May 27, 2007 11:00 pm

Re: Selecting some text

Postby Bego » Mon May 28, 2007 8:13 pm

Errrrr, can you pls post a before and after example ?
No clue what you want to do....
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Selecting some text

Postby gstola » Mon May 28, 2007 10:51 pm

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
User avatar
gstola
Newbie
 
Posts: 2
Joined: Sun May 27, 2007 11:00 pm

Re: Selecting some text

Postby jorrasdk » Tue May 29, 2007 7:13 am

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();
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Selecting some text

Postby Mofi » Tue May 29, 2007 7:24 am

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts