Writing help files (.TPH)

Posted on 1999-09-25
Medium Priority
Last Modified: 2010-04-16
I write a unit in Turbo Pascal 7. I want to write a help for my projecdures and functions. Can I write a .tph file and link it with main Turbo Pascal Help file. Is there any tool to do so ?

Please help me to write help

Question by:Motaz
  • 3
  • 2

Expert Comment

by:My name is Mud
ID: 2080732
Did it work???

Expert Comment

ID: 2087602
I may be wrong, but isn't there some "Files to search" option in the Help menu? I'm pretty positive there is.
Then simply add your file there.

Expert Comment

ID: 2092146
Try this address:
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.


Expert Comment

by:My name is Mud
ID: 2092888
That's windows Help Format, Duh...

Accepted Solution

kamarey earned 200 total points
ID: 2093178
I am sorry, may be this an answer:

Subject: Re Help file format

Expanded information on Help file sources.
   In an earlier message I referred to four authors for the book in (1)
below - my mistake - there are three.

(1) 'A Programmer's Guide to Turbo Vision' by Ertl, Machholz and Golgath,
authored by the Pascal product management team at Borland in Germany.
Pub. Addison-Wesley, ISBN 0-201-62401-X.
The book contains chapter 12 ( 18 pages ) describing how to add a
context sensitive help unit to your own TV program.
The use of TVHC is described ( 2 pages ). TVHC generates helptxt.pas and
helptxt.hlp files from a special helptxt.txt file. The .pas file is
included in your main routine as a unit. The Helpfile unit is also needed,
this unit, TVHC and a working example are in the TVDEMO subdirectory.
This .hlp file is NOT compatible with the Borland supplied DOS help files,
these have a name of the form *.t*h. I believe I am correct in stating that,
other than demohelp.hlp, all supplied *.hlp files are for windows use.

(2) The 'Borland Open Architecture Handbook for Pascal' describes and
supplies the program HL.EXE. Chapter 8 tells you '...how to create, build,
and maintain Borland DOS Help files'. I have attached information gleaned
from this book.
There are two sections, the first is information taken from the book and
the second is a Unit holding data structures.

look for the *****cut here*****.

******************cut here*********************
{  See `Borland Open Architecture Handbook for Pascal' pages 170-177 }
Binary help file format -

Records are grouped in four sections

 1 - file stamp
 2 - file signature
 3 - file version
 4 - Record Headers
   a - file header record
   b - context
   c - text
   d - keyword
   e - index
   f - compression record
   g - indextags {= subheadings, = qualifiers}


 1 - A file stamp is a null terminated string, note case,
      `TURBO PASCAL HelpFILE.\0' or
      `TURBO C Help FILE.\0'  identifying the file in readable form.
      The null character is followed by a Dos end-of-file charcater $1A.
      This is defined as ;STAMP in the help source file.

 2 - The file signature for Borland products is a null terminated
      string `$*$* &&&&$*$' (no quotes in help files).
      This is defined as ;SIGNATURE in the help source file.

 3 - The file version is a record of two bytes that define the version
      of help format and the help file text respectively,

        TPVersionRec    = record
          Formatversion : byte;
          TextVersion   : byte   {defined with ;VERSION}
          { this is for info only }
      FormatVersion for BP7     = $34
                        TP6     = $33
                        TP5     = $04
                        TP4     = $02
                        TC++3.0 = $04

 4 - Record Headers -
  All the remaining records have a common format that includes a header
  identifying the record's type and length.

      TPrecHdr  = record;
        RecType   : byte;
        RecLength : word;

  Field RecType is a code that identifies the record type.
      RecType =
        (RT_FileHeader,    {0}
         RT_Context,       {1}
         RT_Text,          {2}
         RT_Keyword,       {3}
         RT_Index,         {4}
         RT_Compression);  {5}
         RT_IndexTags,     {6 - only in FormatVersion $34}

  Field RecLength gives the length of the contents of the record in
  bytes, not including the record header. The contents begin with the
  first byte following the header.

  The field `Rectype' types are explained in the following text.

  Although this structure allows an arbitrary order of records, existing
  Borland products assume a fixed record ordering as follows:-
        file header record
        compression record
        context table
        index table
        indextags record {introduced in BP7}
        text record
        keyword record

 4.a The file header record defines various parameters and options
  common to the help file.

    TPfileHdrRec     = record
      Options        : word;
      MainIndexScreen: word;
      Maxscreen size : word;
      Height         : byte;
      Width          : byte;
      LeftMargin     : byte;

      Options - is a bitmapped field. Only one option currently
                OF_CaseSense ($0004) (C only, not Pascal)
                  if set, index tokens are listed in mixed case
                  in the Index record, and index searches will
                  be case sensitive.
                  if cleared, index tokens are all uppercase in
                  the Index record, and index searches will ignore
                  Defined with ;CASESENSE.

      MainIndexScreen - this is the number assigned to the context
                  designated by the ;MAININDEX command in the help
                  source file.
                  If ;MAININDEX is not used, MainIndexScreen is set
                  to zero.

      MaxScreenSize - this is the number of bytes in the longest text
                  record in the file (not including the header). This
                  field is not currently in use.

      Height, Width - This is the default size in rows and columns,
                  respectively, of the display area of a help window.
                  Defined with ;HEIGHT and ;WIDTH.

      LeftMargin - Specifies the number of columns to leave blank on
                  the left edge of all rows of help text displayed.
                  Defined with ;LEFTMARGIN.

 4.b Context table -
  This is a table of absolute file offsets that relates Help contexts to
  associated text. The first word of the record gives the number of contexts
  in the table.
  The remainder of the record is a table of n ( n given by first word)
  integers (LSByte first). The table is indexed by context number (0 to
  The 3-byte integer at a given index is an absolute byte that is offset in
  the Help file where the text of the associated context begins.
  The 3-byte integer is signed (2's complement).
  Two special values are defined -
        -1 use Index Screen text (defined in File Header record).
        -2 no help available for this context.
  Context table entry 0 is not used.

 4.c text descriptions -
  The text record defines the compressed text of context.
  Text records and keywords appear in pairs, with one pair for each
  context in the file. The text record always precedes its associated
  keyword. Text records are addressed through the file offset values
  found in the context table described above.

  The RecLength field of the text record header defines the number
  of bytes of compressed text in the record.
  The Compression record defines how the text is compressed.
  If the text is nibble encoded, and the last nibble of the last byte
  is not used, it is set to 0.
  Lines of text comprising the the text record are stored as null
  terminated strings.

 4.d the keyword record defines keywords embedded in the preceeding text
  record, and identifies related text records.
  The record begins with the following fixed fields:
    UpContext   : word;
    DownContext : word;
    KeyWordCnt  : word;

  UpContext and DownContext give the context numbers of the previous
  and next sections of text in a sequence, either may be zero,
  indicating the end of the context chain.

  KeyWordCnt gives the number of keywords encoded in the associated
  text record.
  Immediately following this field is an array of Keyword Descriptor
  records of the following form:
      TPKwDesc = record;
        KwContext: word;

  The keywords in a text record are numbered from 1 to KeyWordCnt in the
  order they appear in the text (reading left to right, top to bottom).

  KwContext is a context number (index into the context table) indicating
  which context to switch to if this keyword is selected by the user.

 4.e Index table -
  This is a list of index descriptors.
  An index is a token (normally a word or name) that has been explicitly
  associated with a context using the ;INDEX command in the source text
  More than one index may be associated with a context, but any given index
  can not be associated with more than one context.
  The list of index descriptors in the Index record allows the text of an
  index token to be mapped into its associated context number.

  The first word of the record gives the number of indexes defined in the
  The remaining bytes of the record are grouped into index descriptors.
  The descriptors are listed in ascending order based on the text of the
  token (normal ascii collating sequence). If the OF_CaseSense flag is not
  in the option field of the File header record, all indexes are in

  Each index descriptor uses the following format:
    LengthCode    : byte;
    UniqueChars   : array of byte;
    ContextNumber : word;

  The bits of LengthCode are divided into two bit fields.
  Bits(7..5) specify the number of characters to carry over from the start
  the previous index token string.
  Bits(4..0) specify the number of unique characters to add to the end of
  inherited characters.

  Field UniqueChars gives the number of unique characters to add.
  e.g. if the previous index token is `addition', and the next index token
  `advanced', we inherit two characters from the previous token (ad), and
  six characters (vanced); thus LengthCode would be $46.

  ContextNumber gives the number of the context associated with the index.
  This number is an index into the context table described above.

 4.f A compression record defines how the contents of text records are
       TPCompress = record
         CompType : byte;
         CharTable: array[0..13] of byte;

  CompType - nibble encoding is the only compression method currently
             in use.
                     const CT_Nibble = 2;
  The text is encoded as a stream of nibbles. The nibbles are stored
  sequentially; the low nibble preceeds the high nibble of a byte.
  Nibble values ($0..$D) are direct indexes into the charTable field of
  the compression record. The indexed record is the literal character
  represented by the nibble. The Help Linker chooses the 14 (13?) most
  frequent characters for inclusion in this table. One exception is that
  element 0 always maps to a byte value of 0.

  The remaining two nibble values have special meanings:
            NC_RawChar = $F;
            NC_RepChar = $E;

  Nibble code NC_Char introduces two additional nibbles that define a
  literal character; the least significant nibble first.

  Nibble code NC_RepChar defines a repeated sequence of a single character.
  The next nibble gives the repeat count less two, (counts 2 to 17 are
  The next nibble(s) define the character to repeat; it can be either a
  single nibble in the range ($0..$D) representing an index into
  CharTable, or it can be represented by a three nibble NC_RawChar

 4.g RT_IndexTags is in FormatVersion $34 only. This provides a means
  for including index sub headings in the help file.
  The record header is followed by a list of variable length tag records
    IndRecType = record;
      windexNumber: word; {index into the RT_Index record }
      StrLen: byte;  {length of tag string(not including terminating 0)}
      szTag: array[0..0] of char; {disable range checking}{zero term tag
   The first structure in the array is a special entry which has the
   windexnumber set to $FFFF, and contains the default ;DESCRIPTION
   in case there are duplicate index entries and no tags were specified.

******************cut here*********************
Unit HelpGlobals;
{ This file contains only the structures which are found in the help files }


  Signature      = '$*$* &&&&*$';   {+ null terminator }
  NC_RawChar     = $F;
  NC_RepChar     = $E;

  FileStamp      = Array [0..32] Of Char; {+ null terminator + $1A }
  FileSignature  = Array [0..12] Of Char; {+ null terminator }

  TPVersion      = Record
                   FormatVersion : Byte;
                   TextVersion   : Byte;

  TPRecHdr       = Record
                   RecType   : Byte; {TPRecType}
                   RecLength : Word;

Const   {RecType}
  RT_FileHeader  = Byte ($0);
  RT_Context     = Byte ($1);
  RT_Text        = Byte ($2);
  RT_Keyword     = Byte ($3);
  RT_Index       = Byte ($4);
  RT_Compression = Byte ($5);
  RT_IndexTags   = Byte ($6);


  TPIndRecType      = Record
                      windexNumber : Word;
                      StrLen       : Byte;
                      szTag        : Array [0..0] Of Char;
                       { disable range checking}

  TPfileHdrRec      = Record
                      Options         : Word;
                      MainIndexScreen : Word;
                      Maxscreensize   : Word;
                      Height          : Byte;
                      Width           : Byte;
                      LeftMargin      : Byte;

  TP4fileHdrRec     = Record                  {derived from sample file}
                      Options         : Word;
                      Height          : Byte;
                      Width           : Byte;
                      LeftMargin      : Byte;

  TPCompress        = Record
                      CompType  : Byte;
                      CharTable : Array [0..13] Of Byte;

  TPIndexDescriptor = Record
                      LengthCode      : Byte;
                      UniqueChars     : Array [0..0] Of Byte;
                      ContextNumber   : Word;

  TPKeyword         = Record
                      UpContext   : Word;
                      DownContext : Word;
                      KeyWordCnt  : Word;

  TPKwDesc          = Record
                      KwContext : Word;

  TmyStream   = object (TBufStream)

  PListRecHdr = ^RListRecHdr;

  RListRecHdr = Record
                PNextHdr : PListRecHdr; {pointer to next list element}
                RRecType : TPRecHdr;    {RecType, RecLength}
                PRecPtr  : Pointer;     {pointer to copy of record}

ContextRecHd  = Record
                NoContexts  : Word;
                PContextRec : Pointer;



Expert Comment

by:My name is Mud
ID: 2093188
Now this is more likely, well almost...

>>Is there any tool to do so ?

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Know here how to troubleshoot AT&T DIRECTV no signal error message with simple, stepwise instructions. Also, if you can resolve issues like blue or black screen.
An Outlook data file aka PST is prone to corruption due to various reasons. A corrupt PST file is always inaccessible. Also, you may lose all your crucial mailbox content at any time. So to fix this corruption and protect the mailbox content from be…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question