Tracer

Previous  Next

 

There are 2 methods to create a MyBASIC2 Tracer Utility.  One is used when you want to create a Tracer feature within your scripting environment and one method when you want to create a Standalone Trace Utility Application.  Both types of Tracer Utilities can coexist and run at the same time.

 

Method 1 - Embedded Tracer Utility

 

1.Register your window using mb_register_trace_window by supplying the Window Handle to the window that will receive the Trace messages
mb_register_trace_window( bas, AfxGetMainWnd()->GetSafeHwnd() );
2.Implement a Message Handler in the registered window to handle WM_COPYDATA messages
3.Process the COPYDATASTRUCT supplied with the WM_COPYDATA message.  This structure contains the TRACE message.  Please see Windows documentation for more details on WM_COPYDATA and COPYDATASTRUCT
 
typedef struct tagCOPYDATASTRUCT {
  ULONG_PTR    dwData;   // Upper Word = Interpreter ID, Lower Word = 'TR'
  DWORD        cbData;   // Specifies the length of the supplied TRACE message
  PVOID        lpData;   // This is the actual TRACE message
} COPYDATASTRUCT, *PCOPYDATASTRUCT;

 

Method 2 - Standalone Tracer Utility

 

1.Create a standalone application
2.Create  a Window with the Class Name MB_TRACE_WINDOW and/or Window Title MB_TRACE_WINDOW.  This is defined in MyBASIC2.h as "MyBASIC2$TRACE_OUTPUT".  Please refer to your Windows documentation on how to create a window with a class name.
3.Process the COPYDATASTRUCT supplied with the WM_COPYDATA message in your MB_TRACE_WINDOW .  This structure contains the TRACE message.  Please see Windows documentation for more details on WM_COPYDATA and COPYDATASTRUCT
 
typedef struct tagCOPYDATASTRUCT {
  ULONG_PTR    dwData;   // Upper Word = Interpreter ID, Lower Word = 'TR'
  DWORD        cbData;   // Specifies the length of the supplied TRACE message
  PVOID        lpData;   // This is the actual TRACE message
} COPYDATASTRUCT, *PCOPYDATASTRUCT;