How to open a help file in the same path as procedure file?

Suppose that I load a procedure file. I can expose it from the menu selection. I can click on the ? icon to see information about it. That information includes its path.

How do I get the path information to the procedure file?

I want to use that path information to open the Help file for the procedure, where the help file should be in the same path (folder) as the procedure file.

Does FunctionPath help?

FunctionPath(functionNameStr)
The FunctionPath function returns a path to the file containing the named function. This is useful in certain specialized cases, such as if a function needs access to a lookup table of a large number of values.

I do it like this:

OpenHelp /INT=0/Z ParseFilePath(1, FunctionPath(""), ":", 1, 0) + "MyHelpFile.ihf"

Thanks. This does it in a broad approach.

Function GetHelp(string funcName, string helpName, [string modName])

    if (ParamIsDefault(modName))
        modName = ""
    endif

    string fldrPath, helpfile = helpName + ".ihf"
    fldrPath = ParseFilePath(1,FunctionPath(modName + funcName),":",1,0)
    NewPath/Z/Q/O procName, fldrPath
    OpenHelp/P=procName helpfile
    //KillPath/Z procName

    return 0
end

I might suggest the need for a ProcedurePath(procName) function to return a corresponding path string to a loaded procedure file.

Oh! A blank input to FunctionPath gets the path to the current function. Of course! Thanks Tony.

Just wanted to point out that an empty string input to FunctionPath will retrieve the path for the currently executing function's proc file.  So, your GetHelp function should be in the same proc file that you want to retrieve the help for... but this is probably obvious.

In reply to by jjweimer

jjweimer wrote:

I might suggest the need for a ProcedurePath(procName) function to return a corresponding path string to a loaded procedure file.

function /S getProcWinFilePath(string strWin)
    GetWindow /Z $strWin file
    return StringFromList(1, S_value) + StringFromList(0, S_value)
end

 

It just dawned on me that you want to show a help file that's in a folder alongside your procedure file. Perhaps your procedure file is somewhere outside the Igor User Files folder, but if it is inside the Igor Procedures folder or User Procedures folder in the User Files folder, DisplayHelpTopic will find your help file. DisplayHelpFile does a brute-force search of all the folders in the Igor Pro Folder and User Files folder. The first time to find your file can be lengthy, but once it finds it once, it's open and it will find it quickly the next time.

As AG just pointed out to me in a private email, DisplayHelpFile does not exist. I meant DisplayHelpTopic.