Tech Note 17: Using the HostTraceLib Shared LibraryJan 27, 2002© NSB Corporation. All rights reserved. |
(Contributed by Adrian Nicolaiev)
NSBHostTraceLib adds handy functions to NS Basic/Palm for
doing tracing of your applications. You won't need to use MsgBox
Function anymore, nor clicking its button :) Your application
will run while you trace it.
To use it, download NSBHostTraceLib.prc to your POSE. It is a
small file, about 1.4k in size. Initialise it in your Startup
code as follows:
Dim Error as Integer LoadLibrary "NSBHostTraceLib","HT" 'case is important Error = HT.NSBHostTraceInit()
To stop it, remember to include in your Termination code as follows:
Error = HT.NSBHostTraceClose()
You will need to download (370k) and follow
instructions about "Reporter" too: Put the file Reporter.exe into \nsbasic\tools. Put the file PalmTrace.dll into the same folder as
the copy of Emulator.exe your are using.
If you are using the Emulator from NS Basic with the built in ROM, you will need to download the
full emulator and obtain a ROM image. Go to the Palm Emulator page at PalmOS.com to get this.
http://www.palmos.com/dev/support/docs/devguide/UsingReporter.html
Files included:
NSBHostTraceLib.INF | The info file for NSBHostTraceLib. Put this in your \nsbasic\lib folder. |
NSBHostTraceLib.prc | The library. Put this into your \nsbasic\lib folder and download it to your POSE. |
HostTraceLib.prj | The NSBasic project showing how to use this Shared Library |
HostTraceLib.zip | All above files in a ZIP file |
1. The NSBHostTraceLib.PRC and NSBHostTraceLib.INF files must be put into \NSBasic\Lib.
2. The library must be loaded using the NSBasic LoadLibrary statement. This statement should be located in the program's Startup code so that the functions will be available throughout the program. The LoadLibrary statement has an optional second parameter to allow you to specify an abbreviated reference name for the library's functions. The examples in this document use "HT" for this reference name. Example:
Program's Startup code:
Sub main() LoadLibrary "NSBHostTraceLib", "HT" End Sub
3. Every time you need to trace something, without Line Feed in Reporter, you will need to do as follows:
Dim MyMessage as String ' just an example Dim MyNumber as Integer ' just an example MyNumber = 100 * Rand() ' just an example Error = HT.NSBHostTraceOutputT("Your Message") ' or MyMessage = Str(MyNumber) Error = HT.NSBHostTraceOutputT(MyMessage)
4. Every time you need to trace something, with Line Feed in Reporter, you will need to do as follows:
Dim MyMessage as String ' just an example Dim MyNumber as Integer ' just an example MyNumber = 100 * Rand() ' just an example Error = HT.NSBHostTraceOutputTL("Your Message") ' or MyMessage = Str(MyNumber) Error = HT.NSBHostTraceOutputTL(MyMessage)
5. If you would rather, in Startup Code, do as follows:
Sub Msg(Message as String) Error = HT.NSBHostTraceOutputT(Message) End Sub Sub MsgL(Message as String) Error = HT.NSBHostTraceOutputTL(Message) End Sub
6. Reporter must be active and it will trace all your messages.