TOC/Index Merge

Introduction

To automatically merge several TOC (or Index) files together into a single TOC (or Index) file, we came up with this simple solution. Maybe not very elegant but it works for the couple of people who need it at the moment. Email us if you need more functionality.

Note that you can currently merge files manually using the FAR Toc/Index Editor window:

  1. Open the target TOC or Index file in the FAR TOC/Index Editor.
  2. For each file you want to include, select "TOC> Import File Content"

But this is slow and tedious work if you regularly merge the same files together.

To automate the merging of files you need to create a .Merge file (see below). If you open a .Merge file in the TOC/Index Editor, FAR will automatically merge all files as the .Merge file, then display the final output in the editor. So this is a good way to test a .Merge file. For Index files the merge command also merges any duplicate items found in the final index file.

You can also use the BatchMergeFile= batch command to run it the merge unattended.

.Merge File

A .Merge file is simply an INI file (a text file with [sections] renamed to .Merge file extension). So you can edit it using any text editor such as Notepad.

The name of the Merge file specifies the name of the output file.
eg. Fred.HHC.Merge  -- When run this will create the output file called Fred.HHC containing a copy of all other files listed in the [Include] section of the Merge file.

File format example:

[BaseFile]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD>
<BODY>
  <OBJECT type="text/site properties">
    <param name="Window Styles" value="0x800025">
    <param name="Font" value="Verdana,9,0">
  </OBJECT>
</BODY>
</HTML>

[Include]
GettingStarted.hhc
WhatsNew.hhc
Customer.hhc
Componenets.hhc
Forms.hhc

FAR creates the output file using the text in the [BaseFile] section, and then imports into that all files listed in the [Include] section.

If you don't specify a [BaseFile] section then the first file listed in the [Include] section will be used.
So basically --

If no BaseFile section found or it's empty then
  copy IncludeFile[0] to Output file
  merge all other Include files into Output file
else
  Create a new Output file using BaseFile section text
  merge all Include files into Output file

Note: The [BaseFile] section is not literal. FAR reads this information but only keeps only the <param name="?" value="?"> settings. You will find if you alter say the <meta ?> statement that this change wont be seen in the Output file.

14-Oct-2011 -- The file encoding for the output file (ANSI/Unicode/UTF-8) is now set the same as the .Merge file.


http://www.HelpwareGroup.com/