DzScript Class Reference
[Script Objects]

Encapsulates a DAZ Script script. More...

Inheritance diagram for DzScript:

DzBase QObject Object List of all members.

Enumerations



enum  ScriptFileMode { UseExtension, TextScriptFile, DAZScriptFile, EncDAZScriptFile }
enum  ScriptLanguage { Unknown, DAZScript1, DAZScript2 }

Methods

void addCode (String code)
void addLine (String line, Number indentLevel=0)
Boolean call (String function, Array args)
Boolean checkSyntax ()
void clear ()
Boolean convertToDAZScript2 ()
Number errorLine ()
String errorMessage ()
Boolean execute (Array args)
Boolean execute ()
DzAuthor getAuthor ()
String getCode ()
String getFilename ()
Boolean getLastStatus ()
ScriptLanguage getScriptLanguage ()
String getScriptType ()
Number getScriptVersion ()
Boolean getShouldReuseInterpreter ()
Boolean isEmpty ()
Boolean isEncrypted ()
Boolean loadFromFile (String filename, Boolean convert=true)
void makeEncrypted ()
Object result ()
DzError saveToFile (String filename, ScriptFileMode mode=UseExtension, String filetype="DAZ Script")
void setCode (String code)
void setContext (DzScriptContext context)
void setReuseInterpreter (Boolean onoff)
Array stackTrace ()
Boolean wasConverted (DzScript::ScriptLanguage language=DzScript::DAZScript1)

Methods (Static)

void addScriptBinaryExtensionsAsMultipleFilters (DzFileFilter filter)
void addScriptBinaryExtensionsToFilter (DzFileFilter filter)
void addScriptOpenExtensionsAsMultipleFilters (DzFileFilter filter)
void addScriptOpenExtensionsToFilter (DzFileFilter filter)
void addScriptSaveExtensionsAsMultipleFilters (DzFileFilter filter)
void addScriptSaveExtensionsToFilter (DzFileFilter filter)
void addScriptTextExtensionsAsMultipleFilters (DzFileFilter filter, Boolean includeDeprecated=false)
void addScriptTextExtensionsToFilter (DzFileFilter filter, Boolean includeDeprecated=false)
Object evaluate (String code, Object context=0, Boolean compatibilityMode=false)
String getScriptFile (String filenameWithoutExtension)
Boolean isScriptBinaryExtension (String ext)
Boolean isScriptBinaryFile (String filename)
Boolean isScriptExtension (String ext)
Boolean isScriptFile (String filename)
Boolean isScriptTextExtension (String ext)
Boolean isScriptTextFile (String filename)

Constructors

 DzScript (DzScript script)
 DzScript (String name="")

Detailed Description

Encapsulates a DAZ Script script.


Member Enumeration Documentation

enum DzScript::ScriptFileMode

Save mode for saving the script to file.

Enumerator:
UseExtension  If the file name extension is .dsb, the file is saved as DAZScriptFile, otherwise as TextScriptFile
TextScriptFile  Plain text file - no Unicode support
DAZScriptFile  Binary DAZ file format - supports Unicode characters
EncDAZScriptFile  Encrypted Binary DAZ file format - supports Unicode characters

enum DzScript::ScriptLanguage

Script language of the file.

Enumerator:
Unknown  Unknown language.
DAZScript1  DAZ Script 1 (QSA) language.
DAZScript2  DAZ Script 2 (QtScript) language.


Constructor & Destructor Documentation

DzScript::DzScript ( String  name = ""  ) 

Constructor.

Parameters:
name The name of the script

DzScript::DzScript ( DzScript  script  ) 

Copy Constructor

Parameters:
script The script to copy.


Member Function Documentation

void DzScript::addCode ( String  code  ) 

Appends the given code to the end of the current script.

Parameters:
code The text to append to the current script.

void DzScript::addLine ( String  line,
Number  indentLevel = 0 
)

Appends the given string and a newline character to the script.

Parameters:
line The text to add to the script.
indentLevel The number of tab characters to insert in front of the line.

DzScript::addScriptBinaryExtensionsAsMultipleFilters ( DzFileFilter  filter  ) 

Parameters:
filter The filter to add the binary extensions to

DzScript::addScriptBinaryExtensionsToFilter ( DzFileFilter  filter  ) 

Parameters:
filter The filter to add the binary extensions to

DzScript::addScriptOpenExtensionsAsMultipleFilters ( DzFileFilter  filter  ) 

Parameters:
filter The filter to add the open extensions to

DzScript::addScriptOpenExtensionsToFilter ( DzFileFilter  filter  ) 

Parameters:
filter The filter to add the open extensions to

DzScript::addScriptSaveExtensionsAsMultipleFilters ( DzFileFilter  filter  ) 

Parameters:
filter The filter to add the save extensions to

DzScript::addScriptSaveExtensionsToFilter ( DzFileFilter  filter  ) 

Parameters:
filter The filter to add the save extensions to

DzScript::addScriptTextExtensionsAsMultipleFilters ( DzFileFilter  filter,
Boolean  includeDepricated = false 
)

Parameters:
filter The filter to add the plain text extensions to
includeDeprecated Whether or not to include the depricated extension(s)

DzScript::addScriptTextExtensionsToFilter ( DzFileFilter  filter,
Boolean  includeDepricated = false 
)

Parameters:
filter The filter to add the plain text extensions to
includeDeprecated Whether or not to include the depricated extension(s)

Boolean DzScript::call ( String  function,
Array  args 
)

Calls a function in the script

Parameters:
function The name of the function to call
args A list of arguments to pass to the function
Returns:
true if the function was called successfully, false if there was an error. The entire script is evaluated before the function call is made.

bool DzScript::checkSyntax (  ) 

Checks the syntax of the script for errors uing the curret interpreter.

Returns:
true if the syntax is valid, otherwise false.

void DzScript::clear (  ) 

Clears any code in the current script, and clears the encryption state if the script was read from an encrypted file.

bool DzScript::convertToDAZScript2 (  ) 

Converts the script to DAZ Script 2 syntax.

Number DzScript::errorLine (  ) 

Returns:
The line number that the last error occured on.

String DzScript::errorMessage (  ) 

Returns:
The last error message gathered from a call to execute(). An empty string if no error has been encountered for this script.

Object DzScript::evaluate ( String  code,
Object  context = 0,
Boolean  compatibilityMode = false 
)

This function is provided as a quick method of evaluating DAZ Script statements without needing to create a DAZ Script object.

Parameters:
code The text string to evaluate as a script
content A pointer to the QObject instance that will provide the script's context.
Returns:
The value returned from the script's execution.

Boolean DzScript::execute ( Array  args  ) 

Execute the script with an argument list This can be called from a thread outside of the gui thread, however the script will not be executed until the gui thread processes events. It returns when execution is complete.

Parameters:
args The list of (string) arguments to pass to the script
Returns:
true if the script was executed successfully, false if there was an error.

bool DzScript::execute (  ) 

Execute the script. This can be called from a thread outside of the gui thread, however the script will not be executed until the gui thread processes events. It returns when execution is complete.

Returns:
true if the script was executed successfully, false if there was an error.

DzAuthor DzScript::getAuthor (  ) 

Returns:
The author of this script if it was loaded from a file with authorship information

String DzScript::getCode (  ) 

Returns:
The code of the current script.

String DzScript::getFilename (  ) 

Returns:
The name and path of the file associated with this script. An empty string if this script is not associated with a file.

bool DzScript::getLastStatus (  ) 

Returns:
true if the last execution was successful, otherwise false.

String DzScript::getScriptFile ( String  filenameWithoutExtension  ) 

Parameters:
filenameWithoutExtension The path to the file, minus the '.' and the extension
Returns:
The path of the file, with extension, of the script found. Otherwise, an empty String.

ScriptLanguage DzScript::getScriptLanguage (  ) 

Returns:
An enumerated value indicating the scripting language of the script

String DzScript::getScriptType (  ) 

Returns:
A string describing the kind of script that this script is

Number DzScript::getScriptVersion (  ) 

Returns:
The version of DAZ Studio that this script was saved out of. The current version if the script was not loaded from a file.

Boolean DzScript::getShouldReuseInterpreter (  ) 

Returns:
Whether the same interpreter is used between calls to the call() function. Default it false.

Boolean DzScript::isEmpty (  ) 

Returns:
true if the script is empty.

Boolean DzScript::isEncrypted (  ) 

Access to the encryption state of the script. If the script is encoded, then getCode() returns '[Content Encrypted]', saveToFile() will not save anything and will return false, also, addLine(), addCode(), and setCode() will have no effect. Calling clear() will clear the encryption state as well as the code.

Returns:
true if the contents of the script are encrypted (i.e. read from an encrypted file)

Boolean DzScript::isScriptBinaryExtension ( String  extension  ) 

Returns:
true if extension is a supported binary script extension

Boolean DzScript::isScriptBinaryFile ( String  filename  ) 

Returns:
true if filename ends with a supported binary script extension

Boolean DzScript::isScriptExtension ( String  extension  ) 

Returns:
true if extension is a supported script extension

Boolean DzScript::isScriptFile ( String  filename  ) 

Returns:
true if filename ends with a supported script extension

Boolean DzScript::isScriptTextExtension ( String  extension  ) 

Returns:
true if extension is a supported [ascii] plain text script extension

Boolean DzScript::isScriptTextFile ( String  filename  ) 

Returns:
true if filename ends with a supported [ascii] plain text script extension

Boolean DzScript::loadFromFile ( String  filename,
Boolean  convert = true 
)

Loads the script from a file.

Parameters:
filename The path to the script file to load.
conver Whether to convert the file to DAZ Script 2.
Returns:
true if the script was successfully loaded, otherwise false.

void DzScript::makeEncrypted (  ) 

Sets the script to be encrypted.

This process is not reversible! Once a script has been made encrypted, its original text can not be extracted. Encrypted scripts can not be edited or modified.

Object DzScript::result (  ) 

Returns:
The result of the last script execution.

DzError DzScript::saveToFile ( String  filename,
ScriptFileMode  mode = UseExtension,
String  filetype = "DAZ Script" 
)

Save the script to a file.

Parameters:
filename The filename of the file to save to
mode The type of file to save.
filetype The filetype that is saved as part of the file information.
Returns:
DZ_NO_ERROR on success, otherwise an error code.

void DzScript::setCode ( String  code  ) 

Replaces the existing code of the script with the given code.

Parameters:
code The new text for the script.

void DzScript::setContext ( DzScriptContext  context  ) 

Sets the context that the script will be executed in.

void DzScript::setReuseInterpreter ( Boolean  onoff  ) 

Wet whether the same interpreter is used between calls to the call() function. Setting this flag clears the interperter. Default it false.

Array DzScript::stackTrace (  ) 

Returns:
The stack trace for the last time an error was reported during a call to execute(). An empty list if no error has been encountered.

Boolean DzScript::wasConverted ( DzScript::ScriptLanguage  language = DzScript::DAZScript1  ) 

Access to whether or not the script was converted from the enumurated value specified.

Returns:
true if the script was converted


Generated on Thu Sep 24 12:21:15 2009

Copyright © 2002 - 2009 DAZ 3D, Inc.