Hi amith, unfortunately there is no way to declare a member private in a JScript or a Script Unit.
There only two places in Test Complete where private members can be defined:
1. In a Script Extension where access to members is controlled by the Description.xml, this has the disadvantage in that a Script Extension must be entirely self contained and cannot reference other Script Units
2. In a JScript Closure using the Module pattern
var MyModule = (function () {
var priv = 123; // Private Var
return {
func: function( value ) { // Public function
priv = priv + value;
return priv;
}
};
})();
Which can be called:
Log.Message( MyModule.func( 123 ) );
The Module pattern has the disadvantage that none of the public members are available in the intellisense.
When I first started using Test Complete, I initially tried using the Module pattern and worried about privates etc.
Eventually, I gave up as it was just to much effort.
Now we rely on documentation, developer discipline and using fully qualified member names, i.e. <ScriptUnit>.<Member>, to call external members on all occasions and don't rely on privates at all.
Regards,
Phil Baird