Replacment for macro command Find Select

Help with writing and running scripts

Replacment for macro command Find Select

Postby Mofi » Sun Oct 21, 2007 9:23 am

Hello script writers!

Do you miss the Find Select method in the script environment to select a block from current cursor position to end of a found string, or to select a block between two strings as you can use it in the macro environment with the command Find Select "..." ?

Yes, then look on the following 2 functions I have developed to make this selection method also available in the script area.

Some Perl experts would say that a Perl regular expression search string can do the same and that is often right, but not always.

If you want to report mistakes or have suggestions for further enhancements post a message here.

The script file FindSelectInnerOuter.js with the code can be viewed or downloaded from the scripts section of the Extra Downloads page.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Replacment for macro command Find Select "..."

Postby maryv » Mon Oct 22, 2007 5:41 pm

Very slick! Thanks!
User avatar
maryv
Basic User
Basic User
 
Posts: 26
Joined: Wed Mar 21, 2007 11:00 pm

Re: Replacment for macro command Find Select

Postby Mofi » Wed Feb 11, 2009 11:21 am

The script file with the 2 functions was updated on 2009-02-10.

I have changed slightly all variable names by adding a prefix letter for the type of the variable. Advantages of using a type prefix letter:

  1. The type of a variable is always visible which is a great help.
  2. No problem anymore with variable names similar common words used in comments or strings, especially for searching/replacing such variables. For example sDirectory as variable name is much better than just Directory because word Directory can also exist in comments and strings.
  3. It is easy to search for all string, number or boolean variables if using a type prefix letter (always lowercase) and the variable name starts with an uppercase character. For example the case sensitive regular expression search string s[A-Z][A-Za-z]+ with option Match Whole Word Only finds all string variables in the script file.
  4. Using type prefix letters makes the selection of an existing variable of type string, number or boolean easier in the auto-complete dialog.
Additionally the global variable used is now named g_nDebugMessage. g_ as additional prefix defines that this variable is a global variable not defined inside the function. Variables with a non standard type don't have a prefix, but have a very special name like WorkingFile.

The standard prefixes I use are:

an ... array of numbers (doesn't exist in FindSelectInnerOuter.js)
as ... array of strings (doesn't exist in FindSelectInnerOuter.js)
b ... boolean
n ... number
s ... string


Further I have added a workaround for a bug of UltraEdit (currently v14.20.1.1008 and confirmend by IDM) in both functions. currentLineNum returns wrong line number if a find was executed before and the found string ends with a line ending character and therefore the cursor is at start of the line below the line(s) with found and selected string (block).

Last I have added a code for demonstrating the usage of the 2 functions. So it is now possible to simply run the script to see the functions in action on a temporarily created new file with example content written into this temp file by the script.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts