Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect
 

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2017 by Barry MacDonnell. All Rights Reserved.

Page updated Nov 27, 2013

AlphaDiv - "Alphabetical List Divider" - Divide any alphabetical list with capital letters

Download ALPHADIV.ZIP (version 1.02; 06/15/12; 19,093 bytes)

Written and tested in WordPerct X6 but should be compatible with WordPerfect 8 and later versions

Downloading, Documentation, Modifications, and Support

Purpose

Alphabetical List Divider.wcm is a macro that divides any alphabetized list of words or short phrases -- such as a generated WordPerfect index or an organization's phone directory -- with either the appropriate capital letter "heading" (A, B, C, etc.) between each section or a blank line between each section. For example:

The initial alphabetized index or list should be composed of words or short phrases. (To divide longer paragraphs, see the alternative macro below.)

Note about v1.02 (06/15/2012): The macro can now optionally detect indented lines (e.g., subheadings in a generated index) to skip past them during processing. It also has an option to insert a hard return after the dividing letters, and an option to enclose dividing letters in text boxes.

Instructions

1. Always make a backup copy of the document first.

2. Be sure to place cursor on the first line of the alphabetical list. (The macro will display a reminder.) The macro starts processing on the current line and continues to the end of the document. The list should not be formatted into tables or columns (these can be added later), and nothing should follow the list.

3. Then play the macro. A small menu will appear.

Options

Several options are available from a menu [image], including letting you choose between using letters or just blank lines to divide the list; setting the relative size of the divider letters; setting the default font or alternative font; the letter color; the justification of the letters (left, center, right); whether to skip over indented lines (such as subheadings in a generated index); and/or put the divider letters in text boxes.

Default values for the menu (and the macro operation) can be set in the macro's User Modification Area at the top of the macro code. Just open the macro for editing with Tools, Macro, Edit. When you have finished making changes click the Save & Compile button on the macro toolbar.

Notes

The alphabetical list should not be inside a column, header, footer, text box, comment, or other substructure. The macro will work only inside normal body text. If the cursor is inside any of those format structures, a warning message will appear and the macro will then exit.

If you require special additional formatting for the list (e.g., set it in columns or tables) you should add that formatting after this macro is played on the list. This probably is best done on the final draft of the document -- especially if the list is a generated index, since re-generating an index completely removes the previous version of the index (including any dividing characters or other special formatting you might have added to the index entries).

The macro contains small optional routines to skip over any indented items such as subheadings in generated indexes, which should not have alphabetical dividers. [The default for this feature can be set in the redlined User Modification Area below.] If you choose to use the option to "Skip over indented lines," which is "On" by default: 

    • The initial cursor position should be on a line whose text begins immediately at the left page margin. This initial left-margin-text-position is stored in a macro variable and it is used to determine if indenting is used further down in the list. it does this by comparing the beginning horizontal position of each line to the initial horizontal position value stored in that variable.
    • Hence, the list should not have any further margin (or other) changes that shifts the horizontal position of the main items in the list away from the margin setting stored in that variable. (You can add such formatting after the macro is played.) Note that secondary items -- such as subheading entries in a generated index -- will normally be automatically indented from the main items by their own special index codes and thus are not part of these general margin shift cautions.

The macro has an option to insert the divider letters inside text boxes. Note that if you wish to Undo this operation with Edit, Undo (or Ctrl+z), you might have to set the program's Undo history to a large amount (even the maximum of 300). Of course, you can always close the list document without saving it, and then reopen it for further processing or testing.


Tips

After the macro plays you could add special formatting to the letters. For example, if you did not choose to use the “Enclose letters in a text box” option you could double-click individual letters and enclose them in a "reverse-text" box with the WordPerfect shipping macro, Reverse.wcm. This turns the letters into white-on-black (or whatever two-color combination works best).

Alternative macro

If you want to create alphabetical headings for paragraphs of text (not just single lines of text, which is what ALPHADIV was designed for), you can manually add letter headings to specific (i.e., chosen) paragraphs with a simple macro, such as the following, which is based on code posted by Charles Rossiter, Corel C_Tech, on the WordPerfect 10 newsgroup. 

It uses the first letter of the paragraph as a heading (divider), so be sure to sort the paragraphs first.

To copy the macro into your WordPerfect, see here.

// Beginning of macro
PosLineBeg
// Skip past any format codes or non-text characters -
While ((?RightCode>0) or (not((CtoN(?RightChar)>32)and(CtoN(?RightChar)<127))))
     PosCharNext
EndWhile
// Select, copy, and paste the letter divider -
SelectCharNext
EditCopy
PosLineVeryBeg
HardReturn
PosLineUp
EditPaste ("Unformatted Text"; 1; OLE!)
// Format the letter divider -
SelectCharPrevious
AttributeAppearanceToggle (Attrib: Bold!)
AttributeRelativeSize (Size: VeryLarge!)
// Return to paragraph -
PosLineDown
Quit
// End of macro

Instructions: Put your cursor on the start of the appropriate paragraph entry (i.e., before all text on the line) and play the macro. It should insert a large, bold letter, one line above the paragraph. You can assign this macro to a toolbar button or keystroke.

Optional code for the above macro: An alternative to using the two Attribute... commands to create the large, bold divider letter is to use a style with the StyleOn command (see below). Be aware, however, that using a system Heading style means the letters will be marked for inclusion in any Table of Contents.

StyleOn (Heading2Style!)

For a larger, centered letter use StyleOn (Heading1Style!) instead.

To insert a space between the letter and the paragraph, add these two commands just after the letter is formatted:

PosLineEnd
HardReturn


Page Top