How does mrScriptBasic compare to Visual Basic?
How does mrScriptBasic compare to VBScript? describes many of the main differences in syntax between mrScriptBasic and VBScript. Most of these differences also apply to Visual Basic. This topic covers the main differences between mrScriptBasic and Visual Basic that do not also apply to VBScript. However, this topic does not cover the differences between VBScript and Visual Basic. For information about VBScript, including information about the differences between VBScript and Visual Basic, see:
Type definition constants
In Visual Basic when you create a reference to a COM component's type library, all of the constants defined in that component are automatically available to your program. Both the names of the constants and of the type definitions are automatically added to the global namespace. This means that you can reference the constants in several ways. For example, if you create a reference to the MDM type library in your Visual Basic program, you can use the MDM oREAD constant when opening an MDM Document. You can reference the constant in any of the following ways:
MDM.Open "myDoc.mdd", oREAD
MDM.Open "myDoc.mdd", openConstants.oREAD
MDM.Open "myDoc.mdd", MDMLib.openConstants.oREAD
MDM.Open "myDoc.mdd", MDMLib.oREAD
When you run a mrScriptBasic file using the /m: option to specify an MDM Document (.mdd) file, the MDM type library is automatically registered. This means that you can use the type definition constants defined in the MDM.
However, mrScriptBasic handles the namespaces differently because of the potential for conflicts when mrScriptBasic is, for example, called within a DataManagementScript (DMS) file when the names of all of the questions are automatically added to the global namespace. mrScriptBasic therefore adds only the type library and the type definition name (and not the constant names) to the global namespace. This means that in mrScriptBasic, you must include the type definition name when you reference one of these constants, otherwise you get an “Undefined variable” error. For example:
MDM.Open("myDoc.mdd", openConstants.oREAD)
MDM.Open("myDoc.mdd", MDMLib.openConstants.oREAD)
When a name conflict occurs between the type definition and a variable, the variable name will take precedence over the type definition name. When this happens, using the type definition name will result in an error.
The mrScriptBasic code you write as part of the OnJobStart, OnNextCase, or OnJobEnd Event sections in a DMS file, automatically has access to all of the MDM, Weight component and Data Management Object Model (DMOM) constants.
Releasing objects
In Visual Basic it is recommended that you release objects. Typically you do this by setting the object to Nothing, for example:
Set MyObject = Nothing
It is not necessary to release objects in this way in mrScriptBasic. However, if you do want to set an object to null, use code like this:
Set MyObject = Null
Functions
mrScriptBasic uses the functions in the
UNICOM Intelligence Function Library, which has been designed for use by the market research industry. This means that some of the functions that are built into Visual Basic are not available in mrScriptBasic. See
Visual Basic function equivalents for more information.
See also