This is the JScript Code:
//*************** Wrapper um globale Variablen für vbScript Standard-Module *******
// define a globalVariable class
function globalVariable() {
// initialize the member variables for this instance
this.ClassName = "globalVariable";
this.Value = null //Util.GetNothing()
// ScriptLang als Funktion, damit einfacher erkennbar in CallSvcClass
globalVariable.prototype.ScriptLang = function() {
return "JavaScript";
}
// in lokalem Kontext freigeben, damit Speicher frei wird
globalVariable.prototype.ShutDown = function() {
if (Util.ObjectIsSet(this.Value)) {
// Unterobjekte..
//if (Util.IsSupportedStd(this.Value, "ShutDown", this.ClassName)) this.Value.ShutDown()
this.Value = null //Util.GetNothing();
}
}
// Objekte zählen lassen
//this._Counter = PVA_0.Debug.CounterProxy_New(this.ClassName, "")
}
function globalVariableCreate()
{
return new globalVariable()
}
I use the globalVariable objects as wrappers to store vbScript Objects in a module context in a way, that their Memory is released when garbageCollect is called in JScript.
This would be the Content of description.XML:
<?xml version="1.0" encoding="UTF-8"?>
<ScriptExtensionGroup Name = "DMS ScriptExtensions">
<Category Name="Runtime Objects">
<ScriptExtension Name = "PVA_Basis" Author = "DMS AG" Version = "1.0" HomePage = "">
<Script Name = "BasisJs.sj">
<RuntimeObject Name = "Util">
<Method Name="globalVariableCreate" Routine="globalVariableCreate">
Globalvariable anlegen zur Ablage in vbs Modul.
</Method>
<Description>
Basisfunktionen für Skripterweiterungen, JavaScript.
</Description>
</RuntimeObject>
</Script>
<Description>
DMS Basisfunktionen für Skripterweiterungen.
</Description>
</ScriptExtension>
</Category>
</ScriptExtensionGroup>
So, You can create the JScript Extension and use it.
In a vbScript module, create a global variable object and assign it to a variable defined in module context.
Then You set its value in a Routine by "Set myVar.Value = objVar".
This should work, You can try it with the Debugger.
Then, in another Routine, You add the following Code:
Dim RegEx, Matches, myKey
Set regEx = New RegExp
regEx.Pattern = "\.[G|V]\d{1,2}"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = RegEx.Execute(myKey)
If Matches.Count > 0 Then myKey = Matches(0).value
'Then, when You retry Routine1, You should get an error at "Set myVar.Value = objVar"