Principle and use of snippets

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

Two types of snippets exist:
  • The snippets that also exist as micropatterns. Their names start with Micropattern. 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. In the List of micropatterns and snippets, these snippets have a "Y" in the "Micropattern calling snippets" column.
    Example: Instead of entering all the parameters of the WF micropattern directly on the micropattern declaration line, you can open the Micro-pattern: W line F snippet. Assign values to its variables in the table of the snippet insertion wizard. If you insert the snippet, a line that contains the variables is inserted in the code. This line has the following format:
    *!WF DSL="CL" DSP="" SEL="01" FOR="I" LEV="1" ORG="2" DES="1" SSC="3" BLC="" GRP=""
  • The snippets that do not call micropatterns. They provide an easy way to insert code. From the variables that you enter in the snippet insertion wizard, the corresponding specific code lines are correctly formatted. When you insert these snippets by dragging them within the code, the inserted code lines do not keep trace of the snippet declaration. In the List of micropatterns and snippets, such snippets have a "Y" in the "Snippets" column.
    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 following way:
  1. Open the .cbl file of a Program, Screen, or Server with the PDP COBOL editor, or the source code of a Macro with the COBOL Source tab of the Macro.
  2. Open the Snippets view. If this view is not displayed, select Window > Show View > Other > General > Snippets.
  3. Expand the line RPP snippets or RPP Macro snippets. Select a snippet and drag it to where you want to insert it in the code. The snippet insertion wizard opens.
    Note: You can also double-click a snippet, or right-click it and select Insert in the contextual menu. The snippet is inserted at the cursor position. To insert it in the correct position, set your cursor on a new line, in column 7, before you open the insertion wizard.
  4. Assign values to the variables that are displayed in the Variables table of the insertion wizard. Details about each variable are given in the Description of variable. You can 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.

Feedback