Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Help Method

This method of the VFP Automation server calls Help. Big surprise.

Usage

oVFP.Help( [ cHelpFile ] [, nContextId | ,, cTopic ] )

No, that’s not a typo: There are two commas before the cTopic parameter. See below for an explanation.

Parameter

Value

Meaning

cHelpFile

Character

The name (including path) of the help file to open.

Omitted

Open the current help file (as specified with SET HELP).

nContextId

Numeric

Position Help on the topic with the specified HelpContextId.

Omitted

If cTopic is also omitted, position Help on the first topic.

cTopic

Character

Position Help on the specified topic. If cTopic doesn't uniquely specify a single topic, show the Help index positioned on the closest match.

Omitted

If nContextId is also omitted, position Help on the first topic.

This is the Automation server equivalent to the native HELP command, except that it actually combines the functionality of both HELP and SET HELP. It’s fairly smart and fairly well-behaved (except for the issues below). The method interacts appropriately with SYS(1023) and SYS(1024), which let you find out the context IDs for dialogs and so forth. Once you call SYS(1023), calls to the Help Method are intercepted as if you’d invoked Help from the interface.

If the right help file is already open, this method’s behavior varies with the type of Help file. For Windows Help files, it just brings the open file to the topic. For HTML Help files, a new instance is opened, if VFP hasn’t already opened it. That is, if you open an HTML Help file outside of VFP, then pass that file name to the Help Method, it gets opened a second time. However, once you do that, as long as you leave it open, the same instance is used.

In VFP 7, when you specify a help file other than the current one, the one you specify becomes the current help file. That is, VFP behaves as though you've SET HELP TO the specified file. We're pretty sure this is a bug, especially since older versions don't behave this way.

Although you can include both a context ID and a topic, only the context ID is processed in that case. If there’s no topic with that ID, it doesn’t matter whether or not the topic is valid—you get an error message.

Watch out when you want to specify only a topic. You do need the extra comma for the missing context ID.

In earlier versions, this method didn't know about HTML Help. If you invoke _VFP.Help from the VFP 6 Command Window, you get an error message. This problem was fixed in VFP 7.

On the other hand, this method handles a wide variety of Windows Help files, bringing up the right version of Help.

Example

* Open VFP 5 Help from a later version
_VFP.Help("\vfp5\foxhelp.hlp")

* Position the currently open Help to the ASSERT command
_VFP.Help(,,"assert")

* Open VFP 5 Help to the topic with context id 536875079
_VFP.Help("\vfp5\foxhelp.hlp",536875079)

See Also

Application, Help, Set Help, Sys(1023), Sys(1024)