Get some SAS tools
Contents Index Conventions First Page Web Site
Next Section Previous Section

Getting the most out of EZRTools;)

Use the Templates

The templates are probably the most useful features for the programmer. They give you the ability to have a standard look to your code (useful when high speed scrolling while looking for a section of code in a large file). Using the templates also means less time spent correcting errors from parameter mismatches in function calls and statement options. Taking the time to learn the letter combinations for the conditional statements saves a lot of time over a week, month, year if you code a lot. (Remember 3 days without programming makes life meaningless). Just compare typing an if-then-do-end combination (17 characters) to iftd (4 characters and a blank). And those numbers don't count the indenting and un-indenting that you are not doing because of the smart indenting available with EZRTools;). So how many lines of code are you supposed to get done per day? How many characters per line? How many of those character combinations are the same 20 words in the same order?

Setting up and using Blocks

Unlike VI and ISPF Edit, in Multi_Edit you select blocks with the mouse (although you can use key combinations) , but you still perform many editing activities with the mouse. Probably the editing activity most often done is repeatedly copying a section of code. If you set the following options this operation is much quicker. Go to the menu item Tools-Customize and select the Block tab. Select the options Turn Block Highlight off after Copy, Turn Block Highlight off after Paste , and Leave cursor at end of block after paste. Now when you want to duplicate a chunk of code, select it leaving the cursor at the beginning of the line after the chunk. Press Cntl-c or right-click and select Copy. Now just press Cntl-v as many times as you need copies.

If you want to use persistent blocks, it is better to select it off the main menu bar under Blocks. Usually, you only need this option temporarily. Selecting Persistent Blocks from the Blocks menu is quicker than going the Tools-Customize route.

Multiple projects, customers, or sites

If you need to report to more than one group or person, you probably already keep the work in separate directory structures. By setting up sessions to point at each directory you can get right to work without having to open and close a bunch of files. First you need to set a few options in Tools-Customize-Sessions . Select the options Encode status files for each directory and Restore screen position on startup. Note, if you want the same session to be active next time you start Multi-Edit, you will need to add a flag to the command that starts Multi-Edit. You can do this by editing the properties of the Multi-Edit shortcut and adding /SR to the Target line.

To create a named session go to File-Session Manager . Select the Create button. You'll get a new entry called "no-name". Give it a name and enter or select (with Browse button) the directory that corresponds to that project, customer or site. Do this for all your projects and you are set.

When you go to work on a particular project just select File-Session Manager and pick the appropriate session. Open all the files you need. When you are finished for now, with that project, don't close any files, just shutdown Multi-Edit or select another session. Next time you select that session all the files you had open appear already open and ready to go. This also preserves any random access marks you may have set in the file.

The Right to Click

Try to minimize switching between mouse and keyboard. When you are typing, it is quicker to use control key combinations like Cntl-i (hops between field strings in expanded templates, Cntl-c to cut. It takes more time to remove your hand from the keys, locate and position the mouse cursor and then relocate your hand back on to the keyboard. In Multi-Edit almost all menu selections, have a corresponding key combination. You can find a searchable list of all the key combinations and their meaning in Tools-Customize-Keys/Commands. Note than when you use menus the key combinations are listed next to the menu items.

Likewise when you are performing mouse operations try to keep using the mouse. Even edit fields (like the search strings for search and replace) can be right clicked to bring up a menu with important items like cut and paste. So it you wanted to search for a particular string among many files you could do it all with mouse by:

  1. Selecting text out of the file you are looking at,
  2. Right click the selected text, select copy from the menu,
  3. Click on Search-File find,
  4. Click on the search string edit box - if it had text it is highlighted,
  5. Right click in the edit box and select paste
  6. Click on the search button.
  7. When the search is over, you can double click the found line and that file will open with your cursor on that line.

Of course, if you were typing, you could use Alt+ keys to navigate the menu and done most of this without touching the mouse. What is important is that you minimize the times you need to switch. Much of EZRTools;)'s tools are accessible from the context sensitive menu (right click in the edit area of a file, left click to select) or as templates that you invoke by typing a few characters followed by a space. This means that if you are typing you don’t need to take your hands off the keys. If you are mousing, then you don’t need the keys. Note if the item you want to search for is a single word, you can place the cursor in the middle of the word, then start the find dialog. With the correct find option set, that word will already be loaded into the Search for text box.

Regular Expressions

If you use VI, you are probably familiar with the use of regular expressions (RE), and wouldn't think of using applications that do not support RE's when applicable. If you have spent time using ISPF you may have seen similar shadows of RE's in batch file editing software. I remember many times having to write a CLIST to change one item to another only if other things were found on the line. The varied and powerful search and replace facilities in Multi-Edit allow a lot of work to be done quickly with out the mind numbing experience of making small changes to large bodies of code.

If you have no familiarity with regular expressions, just learn the Unix style. (You need to check the UNIX style regular expressions option in the Find Options tab of the Search dialog.) After all, there is a high probability that you will end up using UNIX someday. Below is a table outlining some of the special symbols used in Multi-Edit as their "UNIX Style" regular expressions (RE). The idea behind RE is that you can describe patterns found in lines of text. You specify these patterns using either constants "abc", "0", "Put x=", etc. or Regular expression operators. Some of the operators indicate a position, like beginning of the line. Others represent partially or loosely specified amounts of other characters. It is these last set of operators (wild cards) that give most people trouble.

Some Regular Expression operators

Positional

 

^

Beginning of line

$

End of line

Wildcard

 

*

Match zero or more of previous char

+

Match one or more of previous char

.

Match any char

Sets and Groups

 

[set]

Match any char in set

[^set]

Match any char NOT in set

|

"Or" char

( )

Encloses a group of expressions

Constants

 

\t

Hard Tab (0x09)

\xHH

HH = string of 2 hex digits

\

Match next char literally

The easiest way to construct and read regular expressions is left to right saying "followed by" in between each group of characters. For instance, let's say you wanted to find all if statements where the variables being tested for equality were X and Y. So lets guess what such a line might look like:

  • if X=0 ...
  • if c=X ...
  • if Y=c ...
  • if c=Y ...
  • if X=Y ...
  • if Y=X ...

And don’t forget an eq could have been used instead of =. So you read this as:

If followed by X or Y or something followed by = or eq followed by X or Y or something

Now what is key about RE's is how we represent (or don’t) the something. The first thought would be to use . meaning any character and * meaning zero or more of the previous to get: .*,zero or more of any character. The pattern changes to:

If followed by X or Y or .* followed by = or eq followed by X or Y or .*

The problem is that this would find every if statement with an eq or = on it. The .* would override the requirement of X or Y. You also can't forget that there may be one or more spaces or tabs between the words (X,Y,if) that we are looking for. The trick to avoiding the runaway wild card is to realize what is critical and what is not. The words X or Y on a line with an IF are critical. The use of a = or eq is critical so you just look for those:

If followed by ( (X or Y) followed by a (eq or =) ) or ( (eq or =) followed by a (X or Y) )

Now if you insert specifications for zero or more blanks or tabs in the appropriate spaces then you are done. Parentheses are used to group, but the | is used to represent a logical or. If our search had to be case sensitive then we can check that box. The implementation of RE in Multi-Edit seems to work best with excessive amounts of parentheses used. So where (X|Y) seems to convey the concept X or Y sometimes its best (especially if X or Y is actually Bob or Sam to do this ((X)|(Y)). It seems excessive, but you will have to decide if you want to take the time to redo the search if it was needed or use extra parentheses.

When the item you want to describe is choices of one character from a set of possibilities the [ ] constructs work well. In the above example you needed to describe zero or more blank or tab characters. Keep in mind no matter how many characters are enclosed in the square brackets, the whole set only counts as one character. To represent tab you use the escape sequence \t. So zero or more tabs or blanks becomes [ \t]*. Now you can put it all together:

If[ \t]*(((X|Y)[ \t]*(eq|=))|((eq|=)[ \t]*(X|Y)))

Which you can read as:

If followed by zero or more tabs or spaces followed by Either X or Y followed by zero or more tabs or spaces followed by eq or = Or Eq or = followed by zero or more tabs or spaces followed by X or Y.

Below is a copy of the RE with spaces added to better visually group it. The spaces would of course mess up the RE, as they would be interpreted as being a requirement in exact placement in the line and in number. Any constants in your RE that aren't enclosed in [] or optional (used with () and |) or followed by one of the repeat characters like * or + must be in the found result. If you are concerned that there might be parentheses involved in the searched for string, we could place \(* (zero or more ('s) and \)* in the appropriate places. Note the use of the \ with the parentheses. This is because parentheses have a special meaning to RE's so you have to escape them for them to have their regular meaning.

If [ \t]* (((X|Y) [ \t]* (eq|=)) | ((eq|=) [ \t]* (X|Y)))

Find all within the same file

A quick way to hop from one spot to another in a large piece of code is the Find all option in the search dialog. Using the Find item under the Search menu select the All button instead of Search. Searching this way, builds a list of all occurrences within the file (remember to check Global Search so it starts from the top. You get a new tab at the bottom of the screen. Pulling up the tab bar exposes a list of all the found lines. Double clicking on of the lines takes the edit window right to that line. So a search for data or proc would give you a list to hop from one proc to another using the contents of the line and the order in the list to identify the locations.

Complex Replacements

Replacing literal string with other literal strings is fairly straight forward. And even replacing one item, anywhere in a line with another when you have specified it with a regular expression (RE) is not complex. Replacing something while retaining the rest of the line that you used to identify that something is another matter. With a little practice it becomes easy for most changes. Nevertheless this technique is very valuable and worth learning.

If you say search for:

if *.+= * x then *.*;

which means

"if followed by (FB) 0 or more blanks FB 1 or more chars FB = FB 0 or more blanks FB blank x blank then FB 0 or more blanks FB 0 or more chars FB ;".

If you want to replace the x with a zzz you need to preserve the if and the one or more characters that proceed the = character and what trails the then. You cant just type the unknown values into the replace string as you could the if and then parts of the statement. The way we preserve that unknown text is by breaking the RE into groups. You can then identify the groups by number (count from zero) in the replace string. So the RE above becomes:

(if *.+)(= *)( x )(then *.*;)

and in the replacement expression we use \0, \1 and \3 to represent the parts of the line we want to keep. The replacement expression becomes:

\0\1 zzz \3

This is a very powerful tool for batch editing. Because you can selectively insert parts of the found content zero or more times you can actually add information very rapidly. For example lets label every if statement with a hanging comment. Your search expression is:

(if *)(.*)( then.*)

and the replace string is:

\0\1\2 /* Check \1 */

The conditional expression in the if statement is captured in group 1. So you can repeat the information from group 1 in the hanging comment placed further out on the line. Feel free to experiment, if the change you want does not happen then use the Undo function off the Edit menu.

Code reuse

Often if you think about a program up front you can visualize how pieces of it will look quite similar. Or maybe some aspect of a program can be reused in other programs. Consider the power of the ability to copy blocks of code, combined with doing complex mass replacements and being able to restrict the replace(s) to a single marked block. Add to that the history lists for the search and replace strings. If you layout the code with a mind to making it easy to do the replacements, you can reuse a lot of code, which comes down to typing less. Adding comments in key places with unique text, facilitates locating those lines for replacement operations. Designing variable names to contain key words also used in comments allows the comments and the code to be changed with the same replacement operation. There are lots of possibilities here. Also see the section of this document on further customizations by you for ideas how to incorporate your own templates.

Indenting and Capitalization

Three useful "block" operations are Indent and Unindent under the Block Menu and Change Case under the Text menu. All of these work by selecting text first, then picking the action off of a menu. The indenting operations are useful for realigning a block of copied text to the indent level that it now belongs. The Change case is useful because in addition to all upper and all lower it also offers "Proper" case like is used in the text for put statements, labels and the like.

Aligning columns

If your work leads you to want to know how many characters in a string, the ruler option is very useful. To turn the ruler on you select Ruler off of the Text menu. The ruler shows up the top of the screen. It has two markers that can be slid along the length. The top one adjusts where the zero point will be. The bottom marks and controls where the cursor is located.

Other Uses

The full set of features available under Multi-Edit is not exploited when working with the SAS language. There may be other features applicable to your other tasks, so you should explore the various menus and options. If you can download/upload files to your host with FTP, the Project menu has selections that work from within Multi-Edit to carry out these tasks. The tools available with the editor even include a reminder notebook, spell checker (that can be set to only look in comments and strings), and a calculator.

Next Section Previous Section

Copyright © 2000- , Martin Works Inc., Text, graphics, and HTML code are protected by US and International Copyright Laws, and may not be copied, reprinted, published, translated, hosted, or otherwise distributed by any means without explicit permission. SAS® is a registered trademark of SAS Institute, Inc. in Cary, NC. Multi-Edit® is a trademark of Multi-Edit Software Inc. All other logos and trademarks in this site are property of their respective owners.