dim ghsObj as GHS.Application
set ghsObj = New GHS.Application
Or if using a scripting language, an Application object would
be created as follows,
dim ghsObj
set ghsObj = CreateObject("GHSCOM.Application")
Note: CreateObject("GHSCOM.Application") should only be used in
scripting languages as this is much slower than the "dim xxx As
GHS.Application" method. VB and VBA support both methods. The
first method is the only way VB Script can create the object.
An example of linking to GHSCOM in the C++ language is provided
in the sample file named CallFromC.cpp that is included with the
GHSCOM distribution.
When linked to the host program, the GHSCOM Application interface
provides three functions that allow sending commands to GHS and
querying for variable values. These functions are described below.
Command
This function provides for execution of a GHS command string.
Only one command should be given in this string since the "|"
command separator is not supported here as it is in the standard
GHS command interface.
VB syntax:
Command(commandString As String)
C/C++ syntax:
HRESULT Command(BSTR commandString)
GetVariableString
This function gets the current contents of a GHS variable as a
string.
VB syntax:
GetVariableString(variableName As String) As String
C/C++ syntax:
HRESULT GetVariableString(BSTR variableName, BSTR* contents)
GetVariableValue
Similar to GetVariableString, this function gets the contents
of a GHS variable as a real numeric value. If the variable is
actually a string-type and cannot be converted to a number, the
returned value is zero.
VB syntax:
GetVariableValue(variableName As String) As Single
C/C++ syntax:
HRESULT GetVariableValue(BSTR variableName, float* value)
Error Handling
GHSCOM supports the ISupportErrorInfo COM interface. This means
that information about errors is available through the VBA "Err"
object or via GetErrorInfo in C++. For example, in VB,
on error resume next
ghsObj.Command("RA")
if Err.Number<>0 then
print Err.Description
Err.Clear
end if
Limitations
As mentioned above, a subset of the GHS Main Program commands
are available through GHSCOM. There is no access to MC, SE, LE,
CG or any module accessed throught the ENTER command.
It should be noted that the GHSCOM interface can access only one
instance of GHSCOM at any time. No matter how many IApplication
objects it creates, they all refer to the same instance of GHS.