This topic has not yet been rated - Rate this topic

IActiveScriptProperty::SetProperty

Updated: March 2009

Sets the property that is specified by the parameter.

HRESULT SetProperty(
// The property value:
    uint dwProperty,  
// Not used: 
    IntPtr pvarIndex,  
// The value of the property: 
    out object pvarValue,  
);
dwProperty

The property value to set.

pvarIndex

Not used.

pvarValue

The value of the property.

The values allowed for dwProperty are described in the following table.

Constant

Value

Meaning

SCRIPTPROP_INTEGERMODE

0x00003000

Forces the scripting engine to divide in integer mode instead of floating point mode. The default value is False.

SCRIPTPROP_STRINGCOMPAREINSTANCE

0x00003001

Allows the string compare function of the scripting engine to be replaced.

SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION 

0x70000002

Informs the scripting engine that no other scripting engines exist to contribute to the global object.

SCRIPTPROP_INVOKEVERSIONING

0x00004000

Forces the JScript scripting engine to select a set of language features to be supported. The default set of language features supported by the JScript scripting engine is equivalent to the language feature set that appeared in version 5.7 of the JScript scripting engine.

Returns one of the following values:

Return Value

Meaning

S_OK

Success.

E_INVALIDARG

An argument is not valid.

E_UNEXPECTED

The call was not expected (for example, the scripting engine has not yet been loaded or initialized).

To enable or disable integer division, invoke SetProperty and convert a Boolean to an Object. By default, the property value is False. If you set it to True, division operations will return only integers.

To enable or disable custom string comparison, invoke SetProperty and pass in an Object value. The object that you pass in must implement the interface IActiveScriptStringCompare. The StrComp method of the IActiveScriptStringCompare interface is called every time that a string compare function is executed.

To select the set of language features to be supported when the JScript scripting engine is initialized, invoke SetProperty and pass a value that corresponds to the language feature set to be enabled for SCRIPTPROP_INVOKEVERSIONING. If this property is set to 1 (SCRIPTLANGUAGEVERSION_5_7), the available language features are the same as those that appeared in version 5.7 of the JScript scripting engine. If it is set to 2 (SCRIPTLANGUAGEVERSION_5_8), the available language features are those that appeared in version 5.7 in addition to new features that were added in version 5.8. By default, this property is set to 0 (SCRIPTLANGUAGEVERSION_DEFAULT), which is equivalent to the language feature set that appeared in version 5.7, unless the host supports a different default behavior. For example, Internet Explorer 8 opts into the JScript language features that are supported by the version 5.8 JScript scripting engine by default when the default document mode for Internet Explorer 8 is "Internet Explorer 8 Standards" mode. Switching the Internet Explorer 8 document mode to Internet Explorer 7 Standards or Quirks mode resets the JScript scripting engine to support only the language feature set that existed in the version 5.7 JScript scripting engine.

Note Note:

SCRIPTPROP_INVOKEVERSIONING should be set only when the JScript scripting engine is being initialized.

The following example shows how to force the scripting engine to use integer division and how to allow overloading of the compare function.

BMLScriptEngine bmlScriptEngine = new BMLScriptEngine();
IActiveScriptProperty scriptProperties = bmlScriptEngine as 
    IActiveScriptProperty;

// Force the scripting engine to use integer division.
Boolean enableIntegerDivision = true;
Object vtIntegerDivInstance = (Object)enableIntegerDivision;
                scriptProperties.SetProperty(SCRIPTPROP_INTEGERDIVISION, 
    System.IntPtr.Zero, ref vtIntegerDivInstance);

// Allow overloading of the compare function.
BMLScriptStringCompare bmlScriptStringCompareInstance = new 
    BMLScriptStringCompare();
Object vtStrCmpInstance = (Object)bmlScriptStringCompareInstance;
scriptProperties.SetProperty(SCRIPTPROP_STRCOMPINST, 
    System.IntPtr.Zero, ref vtStrCmpInstance);

Date

History

Reason

March 2009

Added information about the SCRIPTPROP_INVOKEVERSIONING property.

Information enhancement.

May 2008

Added topic.

Information enhancement.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
when calling from C++ ensure you use the correct VARIANT type
Important: SetProperty with SCRIPTPROP_INVOKEVERSIONING only takes a VARIANT of type VT_I2 or VT_I4. Any of the other 18 variant integer formats are rejected as invalid.
JScript 5.8 in WSH?
How can I set this property to have access to JScript 5.8 features in Windows Script Host ?
I would like to use Object.defineProperty().
JSON in ASP?
How can I invoke a call to this SetProperty method in order to activate the JScript 5.8 feature set from ASP?
I wish to use the JSON object but it is not available by default.