Help Builder Extension Program

Help Builder includes a Visual FoxPro startup hook program, that if found is executed on startup. This can be very useful in extending Help Builder's built-in functionality with any custom code. With this feature you can:

  • Run custom code at startup
  • Define custom classes/function accessible from script pages

How it works

By default no custom hook program runs. In order to enable this capability, create a file called HELPBUILDER_EXTENSION.PRG and place it in the Help Builder startup directory.

If the file is found Help Builder will compile the file and load any functions/classes contained within it and make it available to your script pages. Help Builder will also execute a specific function at startup: HelpBuilder_Extension_Init(). This function is loaded called when Help Builder first starts after Help Builder has initialized but before a form is loaded.

Here's what the HelpBuilder_Extension.prg file might look like:

* **Custom Initialization Code
FUNCTION HelpBuilder_Extension_Init()

MessageBox("Hello this is my custom Initialization Code")

ENDFUNC

* **Custom functions that can be called from HTML Template pages
* **<%= CopyRightNotice() %>
FUNCTION CopyrightNotice() 
RETURN "(c) West Wind Technologies, " + TRANSFORM(YEAR(2005))

Note that the file uses Visual FoxPro code.

What can you do with this?

This feature is quite powerful in that you can with this write custom code that can be used in your templates. You can also load external FoxPro or COM libraries. For example:

* **Custom Initialization Code
FUNCTION HelpBuilder_Extension_Init()

* **Load a compiled class or UDF library
SET PROCEDURE TO MyExternalLibraryFunction in MyExternalLibrary.EXE ADDITIVE

* **Load uncompiled PRG files and SET PROCEDURE TO
CompileAndLoadHelpBuilderExtension( "someOtherLibrary.prg" )

* **Make a COM object globally visible to your templates
PUBLIC oMyComObject
__oMyComObject = CREATEOBJECT("MyComObject.Server")

ENDFUNC

Note that you can make any objects or other variables PUBLIC in order to have them visible in your templates. I recommend if you do this, that you use a __ prefix to avoid any potential variable naming conflicts.

Error Handling

Nope, no error handling here. Help Builder will load this PRG file if it can find it, and if there are no errors it compiles it. If there are errors it will simply skip over the code. In short, you need to be responsible for your own error handling especially in any routines that might get called as part of the page templates.


© West Wind Techologies, 1996-2023 • Updated: 08/12/15
Comment or report problem with topic