TQAxScript Class

Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQAxScript Class Reference
[TQAxContainer module]

The TQAxScript class provides a wrapper around script code. More...

This class is part of the TQt ActiveTQt Extension.

`#include <qaxscript.h>`

Inherits TQObject.

List of all member functions.

## Public Members

- enum FunctionFlags { FunctionNames = 0, FunctionSignatures }
- TQAxScript ( const TQString & name, TQAxScriptManager * manager )
- ~TQAxScript ()
- bool load ( const TQString & code, const TQString & language = TQString::null )
- TQStringList functions ( FunctionFlags flags = FunctionNames ) const
- TQString scriptCode () const
- TQString scriptName () const
- TQAxScriptEngine * scriptEngine () const
- TQVariant call ( const TQString & function, const TQVariant & var1 = TQVariant ( ), const TQVariant & var2 = TQVariant ( ), const TQVariant & var3 = TQVariant ( ), const TQVariant & var4 = TQVariant ( ), const TQVariant & var5 = TQVariant ( ), const TQVariant & var6 = TQVariant ( ), const TQVariant & var7 = TQVariant ( ), const TQVariant & var8 = TQVariant ( ) )
- TQVariant call ( const TQString & function, TQValueList<TQVariant> & arguments )

## Signals

- void entered ()
- void finished ()
- void finished ( const TQVariant & result )
- void finished ( int code, const TQString & source, const TQString & description, const TQString & help )
- void stateChanged ( int state )
- void error ( int code, const TQString & description, int sourcePosition, const TQString & sourceText )

## Detailed Description

This class is defined in the TQt ActiveTQt Extension, which can be found in the `qt/extensions` directory. It is not included in the main TQt API.

The TQAxScript class provides a wrapper around script code.

Every instance of the TQAxScript class represents a piece of scripting code in a particular scripting language. The code is loaded into the script engine using load(). Functions declared in the code can be called using call().

The script provides scriptEngine() provides feedback to the application through signals. The most important signal is the error() signal. Direct access to the TQAxScriptEngine is provided through the scriptEngine() function.

Warning: This class is not available with the bcc5.5 and MingW compilers.

## Member Type Documentation

### TQAxScript::FunctionFlags

This FunctionFlags enum describes formatting for function introspection.

- `TQAxScript::FunctionNames` - Only function names are returned.
- `TQAxScript::FunctionSignatures` - Returns the functions with signatures.

## Member Function Documentation

### TQAxScript::TQAxScript ( const TQString & name, TQAxScriptManager * manager )

Constructs a TQAxScript object called name and registers it with the TQAxScriptManager manager. This is usually done by the TQAxScriptManager class when loading a script.

A script should always have a name. A manager is necessary to allow the script code to reference objects in the application. The manager takes ownership of the object.

### TQAxScript::~TQAxScript ()

Destroys the object, releasing all allocated resources.

### TQVariant TQAxScript::call ( const TQString & function, const TQVariant & var1 = TQVariant ( ), const TQVariant & var2 = TQVariant ( ), const TQVariant & var3 = TQVariant ( ), const TQVariant & var4 = TQVariant ( ), const TQVariant & var5 = TQVariant ( ), const TQVariant & var6 = TQVariant ( ), const TQVariant & var7 = TQVariant ( ), const TQVariant & var8 = TQVariant ( ) )

Calls function, passing the parameters var1, var1, var2, var3, var4, var5, var6, var7 and var8 as arguments and returns the value returned by the function, or an invalid TQVariant if the function does not return a value or when the function call failed.

See TQAxScriptManager::call() for more information about how to call script functions.

### TQVariant TQAxScript::call ( const TQString & function, TQValueList<TQVariant> & arguments )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Calls function passing arguments as parameters, and returns the result. Returns when the script's execution has finished.

See TQAxScriptManager::call() for more information about how to call script functions.

### void TQAxScript::entered ()`[signal]`

This signal is emitted when a script engine has started executing code.

### void TQAxScript::error ( int code, const TQString & description, int sourcePosition, const TQString & sourceText )`[signal]`

This signal is emitted when an execution error occured while running a script.

code, description, sourcePosition and sourceText contain information about the execution error.

### void TQAxScript::finished ()`[signal]`

This signal is emitted when a script engine has finished executing code.

### void TQAxScript::finished ( const TQVariant & result )`[signal]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

result contains the script's result. This will be an invalid TQVariant if the script has no return value.

### void TQAxScript::finished ( int code, const TQString & source, const TQString & description, const TQString & help )`[signal]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

code, source, description and help contain exception information when the script terminated.

### TQStringList TQAxScript::functions ( FunctionFlags flags = FunctionNames ) const

Returns a list of all the functions in this script if the respective script engine supports introspection; otherwise returns an empty list. The functions are either provided with full prototypes or only as names, depending on the value of flags.

See also TQAxScriptEngine::hasIntrospection().

### bool TQAxScript::load ( const TQString & code, const TQString & language = TQString::null )

Loads the script source code written in language language into the script engine. Returns true if code was successfully entered into the script engine; otherwise returns false.

If language is empty (the default) it will be determined heuristically. If code contains the string `End Sub` it will be interpreted as VBScript, otherwise as JScript. Additional scripting languages can be registered using TQAxScript::registerEngine().

This function can only be called once for each TQAxScript object, which is done automatically when using TQAxScriptManager::load().

### TQString TQAxScript::scriptCode () const

Returns the script's code, or the null-string if no code has been loaded yet.

See also load().

### TQAxScriptEngine * TQAxScript::scriptEngine () const

Returns a pointer to the script engine.

You can use the object returned to connect signals to the script functions, or to access the script engine directly.

### TQString TQAxScript::scriptName () const

Returns the name of the script.

### void TQAxScript::stateChanged ( int state )`[signal]`

This signal is emitted when a script engine changes state. state can be any value in the TQAxScriptEngineState enumeration.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.