Difference between revisions of "Snippets"

From MidrangeWiki
Jump to: navigation, search
m
 
(64 intermediate revisions by 3 users not shown)
Line 3: Line 3:
  
 
==SNIPPETS==
 
==SNIPPETS==
 +
A snippet is a sort of code template or skeleton that allows you to quickly set up a commonly used code fragment like a subprocedure definition (in ILE [[RPG]]).  Snippets are available from WDSC 7.0 up. 
 +
 +
This differs from code [[template]]s because the code template is invoked by the code completion facility {{keypress|Ctrl|Space}}. 
 +
 +
Code completion with templates requires you to start keying the 'trigger' (in RPG, usually the operation code.) 
 +
 +
With snippets, you can have [[WDSC_LPEX|Lpex]] include anything at all, with no trigger needed aside from the double click on the selected snippet.
  
  
Line 10: Line 17:
  
 
To open a snippets view:
 
To open a snippets view:
*Window -> Show view -> Other -> Basic -> Snippets
+
*Enable XML Developer capability:
 
+
**Window → Preferences → General → Capabilities, and then check XML Developer.
Return to [[#TOP]]
+
*Window → Show view → Other → Basic → Snippets
  
 +
[[#top]]
  
 
===Create a Snippets Category ===
 
===Create a Snippets Category ===
Line 22: Line 30:
 
*Create as many Categories as you wish.
 
*Create as many Categories as you wish.
  
* -Right-click in the Snippets view and select Customize
+
* -Right-click in the Snippets view and select {{keypress|Customize...}}
* -Click the New button and create a new category
+
* -Click the {{keypress|New}} button and create a {{keypress|New Category}}
* -Click the New button and create a new snippet
+
* -Click the {{keypress|New}} button and create a {{keypress|New Item}}
* -Click on the snippet and then click the New button that is adjacent to the Variables list
+
* -Click on the snippet and then click the {{keypress|New}} button that is adjacent to the Variables list
 
* -Enter your snippet and use the Insert Variable Placeholder button to add the variable
 
* -Enter your snippet and use the Insert Variable Placeholder button to add the variable
 +
 +
alternatively use the copy, right click process below, its easier.
  
 
Use snippets for RPGLE, CLLE, DSPF and PRTF source members.  
 
Use snippets for RPGLE, CLLE, DSPF and PRTF source members.  
  
  
Return to [[#TOP]]
+
[[#top]]
  
 
===Snippets RPG ===
 
===Snippets RPG ===
Line 41: Line 51:
 
*you can open the view in RSE or iSeries Editing perspective,  
 
*you can open the view in RSE or iSeries Editing perspective,  
 
*select your source,  
 
*select your source,  
*and right click / Past in the snippets view.   
+
*then Right Click / Paste in the snippets view, into your Previously created Category.   
  
 
It will then create a new template.
 
It will then create a new template.
Line 56: Line 66:
 
Another method is to create a Snippet.
 
Another method is to create a Snippet.
  
1. Open the Snippets view.
+
# Open the Snippets view.
2. Create a new 'Drawer' for your snippets.
+
# Create a new 'Drawer' for your snippets.
3. Copy some source.
+
# Copy some source.
4. Right-click in your snippet drawer, paste.
+
# Right-click in your snippet drawer, paste.
5. This will bring up the snippet creation wizard.
+
# This will bring up the snippet creation wizard.
 +
 
 +
===Long Procedure Name===
 +
original post [http://archive.midrange.com/wdsci-l/200806/msg00002.html]
 +
 
 +
How do I get the PR to stay at the same column position, irrespective of what name I use for the procedure ?
 +
 
 +
Use:
 +
 +
D ${Procedure}...
 +
                          PR 
 +
 
 +
Otherwise the procedure name has to always be 12 characters in length. With the elipsis (...) it can be up to 60 odd characters in length.
 +
 
 +
 
 +
[[#top]]
 +
 
 +
 
 +
===Exporting and importing snippets===
 +
ref [[http://archive.midrange.com/wdsci-l/200807/msg00325.html]]
 +
 
 +
Snippets can be transferred to another PC by the process of exporting and importing. 
 +
 
 +
You export on the PC you want to copy the snippets from, and import on the PC you want to copy them to.
 +
 
 +
====Exporting====
 +
* In the Snippets view right click and select Customize
 +
* Select your custom snippet category
 +
* Select {{keypress|Export}} (top of the category list, left side)
 +
* See the 'Save as...' dialogue box, remember the file name you chose!
 +
* Copy/FTP/email that XML file to the target PC
 +
 
 +
====Importing====
 +
* Get a snippets XML file some place where it's available to WDSC
 +
* In the Snippets view right click and select Customize
 +
* Select your custom snippet category
 +
* Select {{keypress|Import}} (top of the category list, left side)
 +
* See the 'Open...' dialogue box. 
 +
* Select the XML file to import
 +
 
 +
====Snippets XML structure====
 +
<?xml version="1.0" encoding="UTF-16"?>
 +
<snippets>
 +
    <category filters="*" id="category_1185380127750" initial_state="0" label="RPG" largeicon="" smallicon="">
 +
        <description/>
 +
        <item category="category_1185380127750" class="" editorclass="" id="item_1207666311828" label="subprocedure" largeicon="" smallicon="">
 +
            <description><![CDATA[Subprocedure skeleton]]></description>
 +
            <content><![CDATA[
 +
      * ${proc_comment}
 +
      p ${proc_name}        b
 +
      d ${proc_name}        pi            10i 0
 +
      d  ${parm_name}                      1a
 +
     
 +
      d rc                            10i 0 inz
 +
 +
      c/free
 +
        return rc;
 +
      /end-free
 +
      p                e]]></content>
 +
            <variable default="Description of procedure" id="name_3" name="proc_comment">
 +
                <description><![CDATA[Description]]></description>
 +
            </variable>
 +
            <variable default="new_parm" id="name_2" name="parm_name">
 +
                <description><![CDATA[Parameter name]]></description>
 +
            </variable>
 +
            <variable default="new_proc" id="name_1" name="proc_name">
 +
                <description><![CDATA[Procedure name]]></description>
 +
            </variable>
 +
        </item>
 +
    </category>
 +
</snippets>
 +
 
 +
 
 +
[[#top]]
 +
 
 +
 
 +
===Examples===
 +
[[Snippets/Examples]]
 +
 
 +
[[#top]]
 +
 
 +
 
 +
===CodeGrabs===
 +
[[Snippets/CodeGrabs]]
 +
 
 +
[[#top]]
 +
 
 +
===Templates===
 +
[[Snippets/Templates]]
 +
 
 +
[[#top]]
 +
 
 +
===UDDS File Displayer===
 +
[[UDDS File Displayer]]
 +
 
 +
[[#top]]
 +
 
 +
===UDDS File Display/Update===
 +
[[UDDS File Display/Update]]
 +
 
 +
[[#top]]
 +
 
 +
 
 +
===RGP  API QDFRTVFD ===
 +
[[rQDFRTVFD]]
  
Return to [[#TOP]]
+
[[#top]]
  
 +
===C  API QDFRTVFD  ===
 +
[[cQDFRTVFD]]
  
==External links==
+
[[#top]]
The official WDSC web page [http://www-306.ibm.com/software/awdtools/wdt400/]
 
  
The WDSC Developer blog [http://wdsc.wordpress.com/]
+
===C version of DISPR ===
 +
[[C version of DISPR ]]
  
WDSC tags on del.ici.ous [http://del.icio.us/tag/wdsc]
+
[[#top]]
  
 
==Categories==
 
==Categories==
 
[[Category:WDSC]]
 
[[Category:WDSC]]

Latest revision as of 19:50, 19 August 2022


SNIPPETS

A snippet is a sort of code template or skeleton that allows you to quickly set up a commonly used code fragment like a subprocedure definition (in ILE RPG). Snippets are available from WDSC 7.0 up.

This differs from code templates because the code template is invoked by the code completion facility Ctrl+Space.

Code completion with templates requires you to start keying the 'trigger' (in RPG, usually the operation code.)

With snippets, you can have Lpex include anything at all, with no trigger needed aside from the double click on the selected snippet.


Snippets View

original post [1]

To open a snippets view:

  • Enable XML Developer capability:
    • Window → Preferences → General → Capabilities, and then check XML Developer.
  • Window → Show view → Other → Basic → Snippets

#top

Create a Snippets Category

original post [2]

  • You only need to create a Category once, conceptually its like CRTSRCPF.
  • Create as many Categories as you wish.
  • -Right-click in the Snippets view and select Customize...
  • -Click the New button and create a New Category
  • -Click the New button and create a New Item
  • -Click on the snippet and then click the New button that is adjacent to the Variables list
  • -Enter your snippet and use the Insert Variable Placeholder button to add the variable

alternatively use the copy, right click process below, its easier.

Use snippets for RPGLE, CLLE, DSPF and PRTF source members.


#top

Snippets RPG

original post [3]

You can use the snippets to insert stuff into your program.

To create your own RPG snippets,

  • you can open the view in RSE or iSeries Editing perspective,
  • select your source,
  • then Right Click / Paste in the snippets view, into your Previously created Category.

It will then create a new template.

To use the snippet;

  • Open a source member for editing.
  • Place the cursor where you want the code.
  • Go to the Snippets view, to the Category where the snippet is.
  • Double click on the snippet and it appears in the source


original post [4]

Another method is to create a Snippet.

  1. Open the Snippets view.
  2. Create a new 'Drawer' for your snippets.
  3. Copy some source.
  4. Right-click in your snippet drawer, paste.
  5. This will bring up the snippet creation wizard.

Long Procedure Name

original post [5]

How do I get the PR to stay at the same column position, irrespective of what name I use for the procedure ?

Use:

D ${Procedure}...
                          PR  

Otherwise the procedure name has to always be 12 characters in length. With the elipsis (...) it can be up to 60 odd characters in length.


#top


Exporting and importing snippets

ref [[6]]

Snippets can be transferred to another PC by the process of exporting and importing.

You export on the PC you want to copy the snippets from, and import on the PC you want to copy them to.

Exporting

  • In the Snippets view right click and select Customize
  • Select your custom snippet category
  • Select Export (top of the category list, left side)
  • See the 'Save as...' dialogue box, remember the file name you chose!
  • Copy/FTP/email that XML file to the target PC

Importing

  • Get a snippets XML file some place where it's available to WDSC
  • In the Snippets view right click and select Customize
  • Select your custom snippet category
  • Select Import (top of the category list, left side)
  • See the 'Open...' dialogue box.
  • Select the XML file to import

Snippets XML structure

<?xml version="1.0" encoding="UTF-16"?>
<snippets>
    <category filters="*" id="category_1185380127750" initial_state="0" label="RPG" largeicon="" smallicon="">
        <description/>
        <item category="category_1185380127750" class="" editorclass="" id="item_1207666311828" label="subprocedure" largeicon="" smallicon="">
            <description><![CDATA[Subprocedure skeleton]]></description>
            <content><![CDATA[
      * ${proc_comment}
     p ${proc_name}        b
     d ${proc_name}        pi            10i 0
     d  ${parm_name}                      1a
     
     d rc                            10i 0 inz

     c/free
        return rc;
      /end-free
     p                 e]]></content>
            <variable default="Description of procedure" id="name_3" name="proc_comment">
                <description><![CDATA[Description]]></description>
            </variable>
            <variable default="new_parm" id="name_2" name="parm_name">
                <description><![CDATA[Parameter name]]></description>
            </variable>
            <variable default="new_proc" id="name_1" name="proc_name">
                <description><![CDATA[Procedure name]]></description>
            </variable>
        </item>
    </category>
</snippets>


#top


Examples

Snippets/Examples

#top


CodeGrabs

Snippets/CodeGrabs

#top

Templates

Snippets/Templates

#top

UDDS File Displayer

UDDS File Displayer

#top

UDDS File Display/Update

UDDS File Display/Update

#top


RGP API QDFRTVFD

rQDFRTVFD

#top

C API QDFRTVFD

cQDFRTVFD

#top

C version of DISPR

C version of DISPR

#top

Categories