You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/qaxscriptmanager.html

231 lines
15 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/activeqt/container/qaxscript.cpp:867 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQAxScriptManager Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQAxScriptManager Class Reference<br><small>[<a href="qaxcontainer.html">TQAxContainer module</a>]</small></h1>
<p>The TQAxScriptManager class provides a bridge between application objects
and script code.
<a href="#details">More...</a>
<p>This class is part of the <b>TQt ActiveTQt Extension</b>.
<p><tt>#include &lt;<a href="qaxscript-h.html">qaxscript.h</a>&gt;</tt>
<p>Inherits <a href="ntqobject.html">TQObject</a>.
<p><a href="qaxscriptmanager-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQAxScriptManager"><b>TQAxScriptManager</b></a> ( TQObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#~TQAxScriptManager"><b>~TQAxScriptManager</b></a> ()</li>
<li class=fn>void <a href="#addObject"><b>addObject</b></a> ( TQAxBase&nbsp;*&nbsp;object )</li>
<li class=fn>void <a href="#addObject-2"><b>addObject</b></a> ( TQObject&nbsp;*&nbsp;object )</li>
<li class=fn>TQStringList <a href="#functions"><b>functions</b></a> ( TQAxScript::FunctionFlags&nbsp;flags = TQAxScript::FunctionNames ) const</li>
<li class=fn>TQStringList <a href="#scriptNames"><b>scriptNames</b></a> () const</li>
<li class=fn>TQAxScript * <a href="#script"><b>script</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name ) const</li>
<li class=fn>TQAxScript * <a href="#load"><b>load</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;code, const&nbsp;TQString&nbsp;&amp;&nbsp;name, const&nbsp;TQString&nbsp;&amp;&nbsp;language )</li>
<li class=fn>TQAxScript * <a href="#load-2"><b>load</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;file, const&nbsp;TQString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>TQVariant <a href="#call"><b>call</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;function, const&nbsp;TQVariant&nbsp;&amp;&nbsp;var1 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var2 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var3 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var4 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var5 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var6 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var7 = TQVariant ( ), const&nbsp;TQVariant&nbsp;&amp;&nbsp;var8 = TQVariant ( ) )</li>
<li class=fn>TQVariant <a href="#call-2"><b>call</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;function, TQValueList&lt;TQVariant&gt;&nbsp;&amp;&nbsp;arguments )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#error"><b>error</b></a> ( TQAxScript&nbsp;*&nbsp;script, int&nbsp;code, const&nbsp;TQString&nbsp;&amp;&nbsp;description, int&nbsp;sourcePosition, const&nbsp;TQString&nbsp;&amp;&nbsp;sourceText )</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>bool <a href="#registerEngine"><b>registerEngine</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name, const&nbsp;TQString&nbsp;&amp;&nbsp;extension, const&nbsp;TQString&nbsp;&amp;&nbsp;code = TQString ( ) )</li>
<li class=fn>TQString <a href="#scriptFileFilter"><b>scriptFileFilter</b></a> ()</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
<p> This class is defined in the <b>TQt <a href="activentqt.html#ActiveTQt">ActiveTQt</a> Extension</b>, which can be found in the <tt>qt/extensions</tt> directory. It is not included in the main TQt API.
<p>
The TQAxScriptManager class provides a bridge between application objects
and script code.
<p> The TQAxScriptManager acts as a bridge between the COM objects embedded
in the TQt application through <a href="qaxobject.html">TQAxObject</a> or <a href="qaxwidget.html">TQAxWidget</a>, and the scripting
languages available through the Windows Script technologies, usually JScript
and VBScript.
<p> Create one TQAxScriptManager for each separate document in your
application, and add the COM objects the scripts need to access
using <a href="#addObject">addObject</a>(). Then <a href="#load">load</a>() the script sources and invoke the
functions using <a href="#call">call</a>().
<p> <b>Warning:</b> This class is not available with the bcc5.5 and MingW
compilers.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQAxScriptManager"></a>TQAxScriptManager::TQAxScriptManager ( <a href="ntqobject.html">TQObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Creates a TQAxScriptManager object. <em>parent</em> and <em>name</em> are passed
on to the <a href="ntqobject.html">TQObject</a> constructor.
<p> It is usual to create one TQAxScriptManager for each document in an
application.
<h3 class=fn><a name="~TQAxScriptManager"></a>TQAxScriptManager::~TQAxScriptManager ()
</h3>
Destroys the objects, releasing all allocated resources.
<h3 class=fn>void <a name="addObject"></a>TQAxScriptManager::addObject ( <a href="qaxbase.html">TQAxBase</a>&nbsp;*&nbsp;object )
</h3>
Adds <em>object</em> to the manager. Scripts handled by this
manager can access the object in the code using the object's <a href="ntqobject.html#name-prop">name</a> property.
<p> You must add all the necessary objects before loading any scripts.
<h3 class=fn>void <a name="addObject-2"></a>TQAxScriptManager::addObject ( <a href="ntqobject.html">TQObject</a>&nbsp;*&nbsp;object )
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Adds a generic COM wrapper for <em>object</em> to the manager. <em>object</em>
must be exposed as a COM object using the functionality provided
by the <a href="qaxserver.html">TQAxServer module.</a>. Applications
using this function you must link against the qaxserver library.
<h3 class=fn><a href="ntqvariant.html">TQVariant</a> <a name="call"></a>TQAxScriptManager::call ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;function, const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var1 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var2 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var3 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var4 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var5 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var6 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var7 = TQVariant ( ), const&nbsp;<a href="ntqvariant.html">TQVariant</a>&nbsp;&amp;&nbsp;var8 = TQVariant ( ) )
</h3>
Calls <em>function</em>, passing the parameters <em>var1</em>, <em>var1</em>,
<em>var2</em>, <em>var3</em>, <em>var4</em>, <em>var5</em>, <em>var6</em>, <em>var7</em> and <em>var8</em>
as arguments and returns the value returned by the function, or an
invalid <a href="ntqvariant.html">TQVariant</a> if the function does not return a value or when
the function call failed. The call returns when the script's
execution has finished.
<p> In most script engines the only supported parameter type is "const
TQVariant&", for example, to call a JavaScript function
<pre>
function setNumber(number)
{
n = number;
}
</pre>
use
<pre>
<a href="ntqvaluelist.html">TQValueList</a> args;
args &lt;&lt; 5;
script-&gt;call("setNumber(const <a href="ntqvariant.html">TQVariant</a>&amp;)", args);
</pre>
As with <a href="qaxbase.html#dynamicCall">dynamicCall</a> the
parameters can directly be embedded in the function string.
<pre>
script-&gt;call("setNumber(5)");
</pre>
However, this is slower.
<p> Functions provided by script engines that don't support
introspection are not available and must be called directly
using <a href="qaxscript.html#call">TQAxScript::call</a>() on the respective <a href="#script">script</a> object.
<p> Note that calling this function can be significantely slower than
using <a href="#call">call</a>() on the respective <a href="qaxscript.html">TQAxScript</a> directly.
<h3 class=fn><a href="ntqvariant.html">TQVariant</a> <a name="call-2"></a>TQAxScriptManager::call ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;function, <a href="ntqvaluelist.html">TQValueList</a>&lt;TQVariant&gt;&nbsp;&amp;&nbsp;arguments )
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Calls <em>function</em> passing <em>arguments</em> as parameters, and returns
the result. Returns when the script's execution has finished.
<h3 class=fn>void <a name="error"></a>TQAxScriptManager::error ( <a href="qaxscript.html">TQAxScript</a>&nbsp;*&nbsp;script, int&nbsp;code, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;description, int&nbsp;sourcePosition, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;sourceText )<tt> [signal]</tt>
</h3>
<p> This signal is emitted when an execution error occured while
running <em>script</em>.
<p> <em>code</em>, <em>description</em>, <em>sourcePosition</em> and <em>sourceText</em>
contain information about the execution error.
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="functions"></a>TQAxScriptManager::functions ( <a href="qaxscript.html#FunctionFlags-enum">TQAxScript::FunctionFlags</a>&nbsp;flags = TQAxScript::FunctionNames ) const
</h3>
Returns a list with all the functions that are available.
Functions provided by script engines that don't support
introspection are not included in the list.
The functions are either provided with full prototypes or
only as names, depending on the value of <em>flags</em>.
<h3 class=fn><a href="qaxscript.html">TQAxScript</a>&nbsp;* <a name="load"></a>TQAxScriptManager::load ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;code, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;language )
</h3>
Loads the script source <em>code</em> using the script engine for <em>language</em>. The script can later be referred to using its <em>name</em>
which should not be empty.
<p> The function returns a pointer to the script for the given
<em>code</em> if the <em>code</em> was loaded successfully; otherwise it
returns 0.
<p> If <em>language</em> is empty it will be determined heuristically. If <em>code</em> contains the string "End Sub" it will be interpreted as
VBScript, otherwise as JScript. Additional script engines can be
registered using <a href="#registerEngine">registerEngine</a>().
<p> You must add all the objects necessary (using <a href="#addObject">addObject</a>()) <em>before</em> loading any scripts. If <em>code</em> declares a function that is
already available (no matter in which language) the first function
is overloaded and can no longer be called via <a href="#call">call</a>(); but it will
still be available by calling its <a href="#script">script</a>
directly.
<p> <p>See also <a href="#addObject">addObject</a>(), <a href="#scriptNames">scriptNames</a>(), and <a href="#functions">functions</a>().
<h3 class=fn><a href="qaxscript.html">TQAxScript</a>&nbsp;* <a name="load-2"></a>TQAxScriptManager::load ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;file, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Loads the source code from the <em>file</em>. The script can later be
referred to using its <em>name</em> which should not be empty.
<p> The function returns a pointer to the script engine for the code
in <em>file</em> if <em>file</em> was loaded successfully; otherwise it
returns 0.
<p> The script engine used is determined from the file's extension. By
default ".js" files are interpreted as JScript files, and ".vbs"
and ".dsm" files are interpreted as VBScript. Additional script
engines can be registered using <a href="#registerEngine">registerEngine</a>().
<h3 class=fn>bool <a name="registerEngine"></a>TQAxScriptManager::registerEngine ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;extension, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;code = TQString ( ) )<tt> [static]</tt>
</h3>
Registers the script engine called <em>name</em> and returns TRUE if the
engine was found; otherwise does nothing and returns FALSE.
<p> The script engine will be used when loading files with the given
<em>extension</em>, or when loading source code that contains the string
<em>code</em>.
<h3 class=fn><a href="qaxscript.html">TQAxScript</a>&nbsp;* <a name="script"></a>TQAxScriptManager::script ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name ) const
</h3>
Returns the script called <em>name</em>.
<p> You can use the returned pointer to call functions directly
through <a href="qaxscript.html#call">TQAxScript::call</a>(), to access the script engine directly, or
to delete and thus unload the script.
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="scriptFileFilter"></a>TQAxScriptManager::scriptFileFilter ()<tt> [static]</tt>
</h3>
Returns a file filter listing all the supported script languages.
This filter string is convenient for use with <a href="ntqfiledialog.html">TQFileDialog</a>.
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="scriptNames"></a>TQAxScriptManager::scriptNames () const
</h3>
Returns a list with the names of all the scripts.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>