|
Evaluating VBScript code
Using the plug-in commands you can evaluate VBScript code.
VB Script code can be evaluated independently of any ole object.
You do not have to create an Ole4D area for running a script.
You can use the VB Script code also to handle the Ole object created inside the plug-in area, to work with objects, to transfer values from VBScript to the 4D variables, and many other things.
Script hosts
In order to execute VBScript code you have to create a script host. A script host is
a VBS interpretor that can be used to execute VBScript code.
You can create the script host by using the OCCreaScriptHost command.
In the 4D event handling methods it is recommended that you do not create and destroy the script host every time an event occurs, because it may lead to increase memory usage and slow execution.
Script hosts are "global" for the 4D application. That is, you can access a script host from all processes - by using it's name. This way you can use the Ole/ActiveX/COM objects created within the script host from all processes.
Executing VBScript code
You can execute VBScript code using the OCRunScript and OCRunScriptA commands.
By using the OCLastError function you can get information on the last error which occurred, and also about the VBScript code line number, character number, and code line content.
How to access the Ole object from VBScript code
In order to be able to manage the Ole object from VBScript code you have to declare the Ole object. This can be done using the OCDeclareObj.
You can also use the Sender property of the SHost object in event handling methods.
You will be then able to manage the Ole object like any other VBScript object.
SHost object
All script hosts contain an object created by the plug-in, named SHost, which can be used to:
from VB Script code.
|