Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 51f7de0838007e2876221e819c82d833 > files > 602

sketch-0.6.13-2mdk.ppc.rpm

<html>
<head>
<title>User's Guide: The Script Registry
</title>
</head>
<body bgcolor=white text=black link=blue vlink=navy alink=red>
<TABLE WIDTH="100%">
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
<TR>
<TD ALIGN="left"><A HREF="usersguide-7.html">The Example Scripts</A></TD>
<TD ALIGN="center"><A HREF="usersguide-5.html">User Scripting
</A></TD>
<TD ALIGN="right"><A HREF="usersguide-9.html">Sketch's API
</A></TD>
</TR>
</TABLE>
<HR NOSHADE>
<H2><FONT face="Helvetica,Arial"><A NAME="N1"></A>The Script Registry
</font></H2>

<P>The script registry contains all user scripts and its contents are used
to create the <b>Script</b> menu. The script registry is implemented in
the (sub-)package <CODE>Sketch.Scripting</CODE>. Because the <CODE>Scripting</CODE>
package is not automatically imported by the <CODE>Sketch</CODE> package, you
have to <CODE>import Sketch.Scripting</CODE> explicitly before accessing the
registry functions.</P>
<P>Functions in the registry package:</P>
<P>
<DL>
<DT><B><A NAME="N2"></A><tt>AddFunction(<i>name</i>, <i>title</i>, <i>function</i>[, <i>kwargs</i>])</tt></B><DD>
<P>Add the function <i>function</i> to the registry under the name
<i>name</i>. <i>name</i> is used internally to identify the script
and should be unique. </P>
<P>The parameter <i>title</i> defines the text for the menu-entry.</P>
<P>The function accepts these optional keyword arguments:</P>
<P>
<DL>
<DT><B><CODE>script_type = <i>type</i></CODE></B><DD>
<P>The type of the script. It can be either <CODE>SafeScript</CODE>
or <CODE>AdvancedScript</CODE>. Both values are defined in the
<CODE>Scripting</CODE> package. The default is <CODE>SafeScript</CODE>.</P>

<DT><B><CODE>menu = <i>menu_spec</i></CODE></B><DD>
<P>Defines the sub-menu the script should appear in. The
<i>menu_spec</i> can be either a string or a tuple of
strings. Each string is the title of a sub-menu.</P>

<DT><B><CODE>args = <i>argtuple</i></CODE></B><DD>
<P>Defines additional positional parameters passed to the
script function after the context parameter.
<i>argtuple</i> must be a tuple containing these
arguments. It defaults to the empty tuple.</P>
</DL>
</P>

</DL>
</P>
<P>Example: Registering the <CODE>abut_horizontal</CODE> script in the sub-menu
<CODE>"Arrange"</CODE></P>
<P>
<table width="100%" cellpadding="10"><tr><td bgcolor="#FFFFD0">
<PRE>
Sketch.Scripting.AddFunction('abut_horizontal', 'Abut Horizontal',
                             abut_horizontal, menu = 'Arrange')
</PRE>
</td></tr></table>
</P>


<HR NOSHADE>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="left"><A HREF="usersguide-7.html">The Example Scripts</A></TD>
<TD ALIGN="center"><A HREF="usersguide-5.html">User Scripting
</A></TD>
<TD ALIGN="right"><A HREF="usersguide-9.html">Sketch's API
</A></TD>
</TR>
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
</TABLE>
</body>
</html>