Rational Programming Patterns

Snippets: principle and use

You use snippets to easily insert specific code in the code of the generated Pacbase instances.

There are two types of snippets:
  • The snippets which also exist as micropatterns. They provide an easy way to insert the corresponding micropattern. When you insert these snippets in the code, you insert the declaration lines of the micropatterns. You are then sure that these declaration lines are correctly formatted. You must generate the instance again to generate the corresponding specific code.
    Example: Instead of entering all the parameters of the WF micropattern directly on the micropattern declaration line, you can open the WF snippet. Assign values to its variables in the table of the snippet insertion wizard. If you insert the snippet, a line showing the variables is inserted in the code, for example:
    *{WF DSL="CL" DSP="" SEL="01" FOR="I" LEV="1" ORG="2" DES="1" SSC="3" BLC="" GRP=""
    *}
  • The snippets which do not exist as micropatterns They provide an easy way to insert code. From the variables you enter in the snippet insertion wizard, the corresponding specific code lines are correctly formatted. When you insert these fragments by dragging them within the code, the inserted code lines do not keep trace of the snippet declaration.
    Example: From the Indexes insertion snippet, the following specific code lines (with the default values) are inserted in the code.
    05           IINDL PICTURE S9(4) VALUE  ZERO.
                05           IINDR PICTURE S9(4) VALUE  ZERO.
                05           IINDM PICTURE S9(4) VALUE +100.
You insert a snippet in the COBOL code of a generated Pacbase instance or in the code of a Macro.
  1. Open, the .cbl file of a Program, Screen, or Server with the PDP COBOL editor, or the design file of a Macro that opens the COBOL Source tab.
  2. Open the Snippets view. If this view is not displayed, select Window > Show View > Other > General > Snippets.
  3. Expand the RPP snippets line. Select a snippet and drag it to where you want to insert it in the code. The snippet insertion wizard opens up for some snippets.
    Note: This wizard does not exist for the WE, WI, and WS snippets. When you drag one of these snippets, the micropattern start and end tags, and identifier are automatically inserted in the code. You must then enter the micropattern parameters in the inserted line.
    Note: If you insert a snippet by double-clicking it or by selecting Insert in its contextual menu, you must set the cursor on a new line, in column 7.
  4. Assign values to the variables displayed in the Variables table of the insertion wizard. Details about each variable are given in the Description of variable . Look at the contents of the Source field to see what is to be inserted in the code.
  5. Click Insert to insert the code lines where the cursor is placed in the code.

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)