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.
qt3/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>QAxScriptManager 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>QAxScriptManager Class Reference<br><small>[<a href="qaxcontainer.html">QAxContainer module</a>]</small></h1>
<p>The QAxScriptManager class provides a bridge between application objects
and script code.
<a href="#details">More...</a>
<p>This class is part of the <b>Qt ActiveQt Extension</b>.
<p><tt>#include &lt;<a href="qaxscript-h.html">qaxscript.h</a>&gt;</tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p><a href="qaxscriptmanager-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QAxScriptManager"><b>QAxScriptManager</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#~QAxScriptManager"><b>~QAxScriptManager</b></a> ()</li>
<li class=fn>void <a href="#addObject"><b>addObject</b></a> ( QAxBase&nbsp;*&nbsp;object )</li>
<li class=fn>void <a href="#addObject-2"><b>addObject</b></a> ( QObject&nbsp;*&nbsp;object )</li>
<li class=fn>QStringList <a href="#functions"><b>functions</b></a> ( QAxScript::FunctionFlags&nbsp;flags = QAxScript::FunctionNames ) const</li>
<li class=fn>QStringList <a href="#scriptNames"><b>scriptNames</b></a> () const</li>
<li class=fn>QAxScript * <a href="#script"><b>script</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name ) const</li>
<li class=fn>QAxScript * <a href="#load"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;code, const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;language )</li>
<li class=fn>QAxScript * <a href="#load-2"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file, const&nbsp;QString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>QVariant <a href="#call"><b>call</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;function, const&nbsp;QVariant&nbsp;&amp;&nbsp;var1 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var2 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var3 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var4 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var5 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var6 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var7 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var8 = QVariant ( ) )</li>
<li class=fn>QVariant <a href="#call-2"><b>call</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;function, QValueList&lt;QVariant&gt;&nbsp;&amp;&nbsp;arguments )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#error"><b>error</b></a> ( QAxScript&nbsp;*&nbsp;script, int&nbsp;code, const&nbsp;QString&nbsp;&amp;&nbsp;description, int&nbsp;sourcePosition, const&nbsp;QString&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;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;extension, const&nbsp;QString&nbsp;&amp;&nbsp;code = QString ( ) )</li>
<li class=fn>QString <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>Qt <a href="activeqt.html#ActiveQt">ActiveQt</a> Extension</b>, which can be found in the <tt>qt/extensions</tt> directory. It is not included in the main Qt API.
<p>
The QAxScriptManager class provides a bridge between application objects
and script code.
<p> The QAxScriptManager acts as a bridge between the COM objects embedded
in the Qt application through <a href="qaxobject.html">QAxObject</a> or <a href="qaxwidget.html">QAxWidget</a>, and the scripting
languages available through the Windows Script technologies, usually JScript
and VBScript.
<p> Create one QAxScriptManager 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="QAxScriptManager"></a>QAxScriptManager::QAxScriptManager ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Creates a QAxScriptManager object. <em>parent</em> and <em>name</em> are passed
on to the <a href="qobject.html">QObject</a> constructor.
<p> It is usual to create one QAxScriptManager for each document in an
application.
<h3 class=fn><a name="~QAxScriptManager"></a>QAxScriptManager::~QAxScriptManager ()
</h3>
Destroys the objects, releasing all allocated resources.
<h3 class=fn>void <a name="addObject"></a>QAxScriptManager::addObject ( <a href="qaxbase.html">QAxBase</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="qobject.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>QAxScriptManager::addObject ( <a href="qobject.html">QObject</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">QAxServer module.</a>. Applications
using this function you must link against the qaxserver library.
<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="call"></a>QAxScriptManager::call ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;function, const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var1 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var2 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var3 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var4 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var5 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var6 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var7 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var8 = QVariant ( ) )
</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="qvariant.html">QVariant</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
QVariant&", for example, to call a JavaScript function
<pre>
function setNumber(number)
{
n = number;
}
</pre>
use
<pre>
<a href="qvaluelist.html">QValueList</a> args;
args &lt;&lt; 5;
script-&gt;call("setNumber(const <a href="qvariant.html">QVariant</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">QAxScript::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">QAxScript</a> directly.
<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="call-2"></a>QAxScriptManager::call ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;function, <a href="qvaluelist.html">QValueList</a>&lt;QVariant&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>QAxScriptManager::error ( <a href="qaxscript.html">QAxScript</a>&nbsp;*&nbsp;script, int&nbsp;code, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;description, int&nbsp;sourcePosition, const&nbsp;<a href="qstring.html">QString</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="qstringlist.html">QStringList</a> <a name="functions"></a>QAxScriptManager::functions ( <a href="qaxscript.html#FunctionFlags-enum">QAxScript::FunctionFlags</a>&nbsp;flags = QAxScript::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">QAxScript</a>&nbsp;* <a name="load"></a>QAxScriptManager::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;code, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qstring.html">QString</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">QAxScript</a>&nbsp;* <a name="load-2"></a>QAxScriptManager::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file, const&nbsp;<a href="qstring.html">QString</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>QAxScriptManager::registerEngine ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;extension, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;code = QString ( ) )<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">QAxScript</a>&nbsp;* <a name="script"></a>QAxScriptManager::script ( const&nbsp;<a href="qstring.html">QString</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">QAxScript::call</a>(), to access the script engine directly, or
to delete and thus unload the script.
<h3 class=fn><a href="qstring.html">QString</a> <a name="scriptFileFilter"></a>QAxScriptManager::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="qfiledialog.html">QFileDialog</a>.
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="scriptNames"></a>QAxScriptManager::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">Qt 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>Qt 3.3.8</div>
</table></div></address></body>
</html>