Command: ScriptCMDRegister
- Mise à jour2024-09-12
- Temps de lecture : 3 minute(s)
Command: ScriptCMDRegister
Command: ScriptCMDRegister
Allows CodeCompletion for encrypted user commands. DIAdem takes the information for CodeCompletion from the TLB file.
Input Parameters
ScriptCMDItemName |
Specifies the name of the function or variable that was registered as user command or with the GlobDim command. |
ScriptCMDTypeLibName |
Specifies the filename of a TLB file. You can enter the file with the absolute path or a filename. If you do not specify a path, DIAdem expects the file to be in the program directory. |
ScriptCMDInterfaceName |
Specifies the name of the interface for which DIAdem displays CodeCompletion. |
The following example shows how to use a TLB file in a user command. Copy the following script into the script editor of DIAdem SCRIPT and save this script in the user folder. Then register the script as a user command.
The script first registers the CMD_register.tlb file in DIAdem. The file is in the example folder. The script defines the GlobalTestObject object variable and the associated VBS classes, properties and methods. The TLB file contains all information that DIAdem needs in order to display the CodeCompletion of the GlobalTestObject object variable in the script editor. If you enter a dot behind the text GlobalTestObject, DIAdem displays a list of all the properties and methods that this object supports. You also can encrypt the user command.
The CMD_register.odl file, which you can also find in the user folder, describes the interface in text form. This file only contains the structure of the class but does not contain any functionality. You can use the Microsoft MIDL compiler to convert the ODL file to a TLB file. Refer to the compiler documentation for more information.
'Create global Variable Dim GlobalTestObject 'Create instance of VBS class and assign to variable Set GlobalTestObject = new MyTestClass 'Register typelib for test class Call ScriptCMDRegister("GlobalTestObject",ProgramDrv & "Examples\Documents\CMD_register.tlb", "TestTypelib.IMyTestClass") 'VBS Class Class MyTestClass Private m_SubClass Private m_PropValue Private Sub Class_Initialize() Set m_SubClass = new MySubTestClass m_PropValue = "Hello" End Sub Private Sub Class_Terminate() Set m_SubClass = Nothing End Sub Public Property Get SubClass Set SubClass = m_SubClass End Property Public Property Get MyTestProp MyTestProp = m_PropValue End Property Public Property Let MyTestProp(newValue) m_PropValue = newValue End Property Public Function MyTestmethod(Param1, Param2) MsgBox Param1 & Param2 End Function End class 'VBS Sub Class Class MySubTestClass Public Sub Say_Hi MsgBox "Hi" End Sub End Class
Related Topics
CodeCompletion | Method: CreateObject for VBS | Method: GetObject for VBS | Registered Type Libraries

