About GPS ToolKit
Introduction
Purchasing GPS ToolKit
Redistributing GPS ToolKit
License Agreement
Support
Getting Started
How to Use GPS ToolKit
Adding GPS ToolKit to a Visual Basic Project
Adding GPS ToolKit to a Visual C++ Project
Adding GPS ToolKit to an Excel Worksheet
Setting up the GPS
How to Use Events
Handling Events in Visual Basic
Handling Events in Visual C++
Handling Events in Microsoft Excel
GPS ToolKit Sample Projects
Handling GPS ToolKit Errors
Reference
Properties
Altitude
AltitudeUnits
ArrivedAtDest
AutomaticOperation
BaudRate
CrossTrackError
DegLabel
DestClosingVelocity
DestWptID
DestWptLatitude
DestWptLongitude
DistUnits
DGPSRefStationID
FixDateTime
FixGood
FixQuality
FixSatellitePRNs
GeoidHeightAboveWGS84Ellipsoid
HDOP
Latitude
LatLonFormat
Longitude
MagVariation
MinLabel
ModeIndicator
NumSatellitesInFix
NumSatellitesInView
OperationMode
OrigToDestMagBearing
OrigToDestTrueBearing
OriginWptID
PDOP
PortHandle
PortName
RangeToDest
RouteContainsAllWpts
RouteName
SatelliteInViewPRNs
SecLabel
Speed
SpeedUnits
TimeSinceLastDGPSUpdate
TrueBearingToDest
TrueCourse
VDOP
WptsInRoute
Methods
Close
GetSatelliteInfo
GetWptLocation
Open
OpenFile
Events
FixUpdate
FileComplete
NavUpdate
RawDataReceived
SatelliteUpdate

Handling GPS ToolKit Errors

GPS ToolKit notifies your application of any errors it encounters through the IErrorInfo interface. Because this is the standard method to communicate error information from a COM object, Visual Basic, Visual C++, and other development environments have built in support for this interface.

Note that, for simplicity, the examples in the reference section do not include error handling constructs.

Visual Basic

GPS ToolKit errors are handled in Visual Basic using the familiar On Error Goto construct. When an error occurs, detailed information can be found in the application's global Err object. For example, the following code traps an error and displays a description in a message box:

Private Sub MySub()
    On Error GoTo MyErrorHandler
    myGPSToolKit.Open "COM1"
    Exit Sub

MyErrorHandler:
    MsgBox Err.Description
End Sub

Visual C++

The wrapper class that Visual Studio creates when adding GPS ToolKit to your project uses the older MFC TRY/CATCH/END_CATCH exception handling macros instead of the C++ try/catch constructs. This means that in most cases, you will want to use the same TRY/CATCH/END_CATCH macros when trapping for GPS ToolKit exceptions. The following example catches any errors and displays a description of the error in a message box:

void MyFunc()
{
    TRY
    {
        m_myGPSToolKit.Open("COM1");
    }

    CATCH(CException, e)
    {
        char lpszError[1024];
        e->GetErrorMessage(lpszError, 1024);

        AfxMessageBox(lpszError);
    }
    END_CATCH
}
If you are not using GPS ToolKit through the automatically generated wrapper class, you may use the normal C++ try/catch construction to trap errors.