Creating Macros

C#Builder offers a macro facility for recording reusable action sequences while building applications. Macro controls are located at the left part of the status bar, below the editor, as shown in Figure 1.21. Table 1.3 describes the macro controls.

Figure 1.21. An active macro in the C#Builder IDE.

graphics/01fig21.jpg

Table 1.3. Macro Controls

CONTROL NAME/DESCRIPTION

PURPOSE

Playback Macro/green arrow

Runs macro

Record Macro/red circle

Begins macro session

Stop Recording Macro/green square

Ends macro session

To get an idea of how this works, the following example steps through creating and running a macro. It is a simple macro that puts an XML documentation comment above a code element. However, it shows the basic elements of how to create macros.

  1. Either create a new project, using the procedure shown earlier in this chapter, or create a new class file in an existing project. To create a new class file, select File, New, Other and then choose New Files under C# Projects to open a class file.

  2. There will be a constructor inside the class definition named Class. Put the caret anywhere on that line.

  3. Click the Record Macro button. Recording has now begun. Take your time because it only records keystrokes, not mouse moves or the speed at which actions take place.

  4. Press the Home key to move to the beginning of the line.

  5. Press Ctrl+right arrow to position the caret at the beginning of text.

  6. Press the Enter key to move the text down one line.

  7. Press the up arrow key to move to the same column, one line higher.

  8. Type /// <summary> and press the Enter key.

  9. Type /// and press the Enter key.

  10. Type /// </summary> only.

  11. Click the Stop Recording Macro button.

An XML documentation macro has just been recorded. The green arrow to the left of the Record Macro button should now be visible. To run this macro, position the caret above any class member that you want documentation comments on and click the green arrow button.



C# Builder KickStart
C# Builder KickStart
ISBN: 672325896
EAN: N/A
Year: 2003
Pages: 165

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net