SEPY Snippets new features
March 28th, 2005
The snippets panel in SEPY (note: CVS version only) now has the added functionality of parameter defaults. You can also insert a snippet without filling in all the parameters first.
If you haven’t used SEPY’s snippets window before, it gives you a way to create small text templates which you can insert into your code quickly and easily, thus speeding up the creation of repetitive pieces of code like documentation stubs or code structures, conditions and loops etc…
To use the new parameter defaults, you insert a parameter into your snippet using the syntax @MyParameter@, adding the default value at the end of the parameter name using =[myvalue]
e.g.
@@MyParamterName=[My Default Value]@@
The parameter will now appear as usual in the entry dialog, and default values will be listed in the entry fields. Clicking the OK button then inserts the snippet into your code at the cursor position.
Tutorial:
This is a quick tutorial for SEPY Snippets to create a code structure using the new defaults system..
Here’s a simple for loop through an array
for(var @@index=[i]@@:Number = 0; @@index@@ < @@ArrayName@@.length; @@index@@ ++)
{
@@ArrayName@@[@@index@@]
}
In this example the code inside the loop is just a simple copy/paste-able reference to our current position in the Array but you can, of course, use the technique to create more complex code structures.
To explain what’s going on here we are declaring the loop @index</b> parameter at the beginning of the <b>for loop</b>, and setting it's default to <b>"i"</b> then we are creating the rest of the code with references to the <b>index@ parameter.
Note that you cannot supply more than one default value for a parameter, as this causes SEPY to throw an error.
When you insert the snippet index will have the default “i” value for the index and you can change it if you need to, once you have filled in the ArrayName and click ok the for loop will be inserted into your code.
Note: This feature is in the CVS version of SEPY only, and as such should be considered unstable.
can you Digg it?
is it del.icio.us? 
Category: General



Leave a Comment
You must be logged in to post a comment .
Trackback this post | Subscribe to the comments via RSS Feed