Chapter 16

DOCUMENT PREPARATION

As a writer, I frequently use over two dozen macros in the preparation of my manuscripts and other documents. Though many are small and simple, with but a single purpose, their overall effect is tremendous. With my regular stable of macros, I save a great deal of time and effort over the old manual methods of document preparation.

If you prepare documents of any type or size, either for yourself or someone else, you'll want to check out the macros in this chapter. You'll find macros for:

 

LINE SPACING FORMATS

Probably the most basic formatting macro you may ever write is to change the line spacing inside your document. WordPerfect requires that you press seven keys just to change the line spacing from 1 to 2. If you are preparing a manuscript with many line space changes, that's a lot of added keystrokes and lost time. The following macros change the existing line spacing to single, one and a half, and double -- the three most common line space settings. The macros are given full text names but you may wish to rename them to [Alt]-letter key combinations so that they can be more easily retrieved.


To Set Single-Space


SINGLE.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. single [Enter] Names macro "SINGLE.WPM."
3. Single space
[Enter]
Describes macro.
4. [Shift]-[F8] Chooses Format menu.
5. L S Selects Line and Space options.
7. 1 [Enter] Sets spacing to 1.
8. [F7] Exits Format menu.
9. [Ctrl]-[F10] Ends macro definition.


To Set Space-and-a-Half


ONEHALF.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. onehalf
[Enter]
Names macro "ONEHALF.WPM."
3. One and a half
[Enter]
Describes macro.spacing
4. [Shift]-[F8] Chooses Format menu.
5. L S Selects Line and Space options.
7. 1.5 [Enter] Sets spacing to 1.5.
8. [F7] Exits Format menu.
9. [Ctrl]-[F10] Ends macro definition.

To Set Double-Space


DOUBLE.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. double
[Enter]
Names macro "DOUBLE.WPM."
3. Double space
[Enter]
Describes macro.
4. [Shift]-[F8] Chooses Format menu.
5. L S Selects Line and Space options.
7. 2 [Enter] Sets spacing to 1.
8. [F7] Exits Format menu.
9. [Ctrl]-[F10] Ends macro definition.

All-in-One Line Spacing

You may wish to set different line spacings, or not like the idea of having three macros to do such a basic job. The macro described below uses WordPerfect's advanced macro language to make line spacing selection easy and efficient. You'll probably want to rename this macro with an Alt-letter name so that you can call it up more quickly.


SPACE.WPM (provided on the Applications Disk)

{IF}{SYSTEM}menu~!=65535~
{QUIT}
{END IF}

{CHAR}key~
{^]}1 O{^\}ne Space  {^]}2 D{^\}ouble Space  
{^]}3 T{^\}riple Space  {^]}4{^\} Othe{^]}r{^\}  
{^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~ 1~
1~ 1~ O~ 1~ o~ 1~
2~ 2~ D~ 2~ d~ 2~
3~ 3~ T~ 3~ t~ 3~
4~ 4~ R~ 4~ r~ 4~
~
{QUIT}

{LABEL}1~
{ASSIGN}key~1~
{GO}setup~
{LABEL}2~
{ASSIGN}key~2~
{GO}setup~
{LABEL}3~
{ASSIGN}key~3~
{GO}setup~
{LABEL}4~
{TEXT}key~Enter line spacing  ~
{GO}setup~
{LABEL}setup~
{DISPLAY OFF}
{Format}LS
{VARIABLE}key~{Enter}
{Exit}


Open Space

Many manuscript formats require open spaces between paragraphs or certain other blocks of text. The open space is an extra line or two between adjacent paragraphs. For example, you might want a format where the lines within the paragraph are double-spaced, but the lines between the paragraphs are triple spaced.


Manual Open Space Macro

The following open space macro simply changes the line spacing, adds the number of extra lines you want, then changes the line spacing back to normal. Here's a macro that puts an extra blank line between double-spaced paragraphs (this macro assumes that the current line spacing format is already 2 when the macro is invoked):


OPEN.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. OPEN1 Names macro.
3. Extra line with double-space
[Enter]
Describes macro.
4. [Shift]-[F8] Chooses Format menu.
5. L S Selects Line and Space options.
7. 1 [Enter] Sets spacing to 1.
8. [F7] Exits Format menu.
9. [Enter] Adds extra line.
10. [Shift]-[F8] Chooses Format menu.
11. L S Selects Line and Space options.
12. 2 [Enter] Sets spacing back to 2.
13. [F7] Exits Format menu.
14. [Ctrl]-[F10] Ends macro definition.

You can use this macro to add an extra blank space between paragraphs of text blocks regardless of the current line spacing format, but you should change the line spacing in Step 12 accordingly. Remember to press the [Enter] key at the end of each paragraph before invoking the macro. You can use this macro before or after the text is written.


Automatic Open Space Macro

This macro automatically inserts the open space each time you press the [Enter] key. Run the macro at the beginning of the document. To cancel the macro and revert to regular spacing between paragraphs, press [F1]. This macro is effective only when you are writing the text.

As shown, the macro resets the line spacing to 2 for the text that follows. Rewrite the macro as needed when using different line spacings. You may wish to create a macro for all the common line spacings you use. Give each macro a unique name, such as AUTOSP1 (for auto-space, one-space), AUTOSP2, etc.


AUTOSP2.WPM (provided on the Applications Disk)

{ASSIGN}2~~
{LABEL}loop~
{VAR 2}
{LOOK}2~
{IF}"{VAR 2}"="{Enter}"~
{ELSE}
{GO}loop~
{END IF}
{DISPLAY OFF}
{Format}LS1
{Enter}{Exit}
{Format}LS2
{Enter}{Exit}
{DISPLAY ON}

 

SETTING MARGINS

Like line spacing, WordPerfect requires you go through more than a half dozen steps to change margins. Unlike line spacing however, where there are only a small number of possible choices, there are an almost unlimited selection of margins you can apply to a WordPerfect documents. And you can set margins in inches, WordPerfect 4.2 units, points, centimeters, even as fine as 1/1,200 of an inch increments.

The MARGIN.WPM macro described here makes it a little easier to set new document margins. You are first prompted for the margin you'd like to set -- left, right, top, or bottom. You then enter a margin setting, and press [Enter]. In a flash, the macro enters all the pertinent formatting information.


MARGIN.WPM (provided on the Applications Disk)

{IF}{SYSTEM}menu~!=65535~
{QUIT}
{END IF}

{CHAR}key~
{^]}1 L{^\}eft Margin  {^]}2 R{^\}ight Margin  
{^]}3 T{^\}op Margin  {^]}4 B{^\}ottom Margin  ~
{CASE}{VARIABLE}key~~
1~ 1~ L~ 1~ l~ 1~
2~ 2~ R~ 2~ r~ 2~
3~ 3~ T~ 3~ t~ 3~
4~ 4~ B~ 4~ b~ 4~
~
{QUIT}

{LABEL}1~
{CALL}set_margin~
{DISPLAY OFF}
{Format}LM
{VARIABLE}key~{Enter}{Enter}
{Exit}{QUIT}
{LABEL}2~
{CALL}set_margin~
{DISPLAY OFF}
{Format}LM
{Enter}{VARIABLE}key~{Enter}
{Exit}{QUIT}
{LABEL}3~
{CALL}set_margin~
{DISPLAY OFF}
{Format}PM
{VARIABLE}key~{Enter}{Enter}
{Exit}{QUIT}
{LABEL}4~
{CALL}set_margin~
{DISPLAY OFF}
{Format}PM
{Enter}{VARIABLE}key~{Enter}
{Exit}{QUIT}
{LABEL}set_margin~
{TEXT}key~Enter the margin setting  ~
{RETURN}

The MARGIN.WPM macro lets you set margin is any increment or value you wish. It is most valuable when you need to set in-between margin sizes, such as 3.17 inches, or 18.76 points. The affect of the margin settings is not immediately recognizable until you print the document, or view it in Print View.

The MARGSET.WPM, shown below, provides an on-screen template of the margins as they will appear on an 8 1/2- by 11-inch piece of paper, and helps you to visualize how the text will look on the page. You can use the cursor keys to adjust the margin settings in 1/2-inch increments.

Because MARGSET.WPM is a large macro, only the important working parts will be described here. The complete working macro is contained on the Applications Disk.

To use the MARGSET macro:

  1. Start the macro in the usual fashion.
  2. The menu in the upper-left corner always appears. You have the following choices:
  1. Pressing the Exit key ([F7]) at any point sets the margins you've currently set and exits the macro. You can cancel the macro at any time by pressing the Cancel key.


MARGSET.WPM (provided on the Applications Disk)

{LABEL}start~
{ON CANCEL}{GO}cancel~~
{ASSIGN}l/r~28~
{ASSIGN}t/b~19~
{ASSIGN}ul_c~26~
{ASSIGN}ll_c~26~
{ASSIGN}ul_r~2~
{ASSIGN}ll_r~21~
{ASSIGN}ur_c~54~
{ASSIGN}ur_r~2~
{ASSIGN}lr_c~54~
{ASSIGN}lr_r~21~
{CALL}page~
{CALL}write~

This section, appearing at the beginning of the macro, sets the initial margins. The variables are assigned screen coordinate numbers, which are later converted to actual margin sizes.

{LABEL}right~
{CALL}erase~
{ASSIGN}ul_c~{VARIABLE}ul_c~+2~
{ASSIGN}ll_c~{VARIABLE}ll_c~+2~
{ASSIGN}ur_c~{VARIABLE}ur_c~+2~
{ASSIGN}lr_c~{VARIABLE}lr_c~+2~
{IF}{VARIABLE}ur_c~>58~
{ASSIGN}ur_c~58~
{ASSIGN}ul_c~{VARIABLE}ur_c~-{VARIABLE}l/r~~
{ASSIGN}ll_c~{VARIABLE}ul_c~~
{ASSIGN}lr_c~58~
{END IF}
{CALL}write~
{GO}move~

You have the option of moving the entire printable area on the page (the Move Margins command). Pressing one of the cursor keys moves all the margins in unison. The section shows the macro code when you press the [Right] cursor arrow. Note that the margins are prohibited from moving beyond the boundaries of the page.

{LABEL}adj_top~
{STATUS PROMPT}{Up}Adjust top margin~
{PROMPT}Press  and  keys to adjust top margin; Enter when done  ~
{LABEL}loop_top~
{LOOK}key~
{IF}"{VARIABLE}key~"="{Up}"~
{CALL}erase~
{ASSIGN}ul_r~{VARIABLE}ul_r~-1~
{ASSIGN}ur_r~{VARIABLE}ur_r~-1~
{IF}{VARIABLE}ul_r~<0~
{ASSIGN}ul_r~0~
{ASSIGN}ur_r~0~
{END IF}
{CALL}write~
{END IF}
{IF}"{VARIABLE}key~"="{Down}"~
{CALL}erase~
{ASSIGN}ul_r~{VARIABLE}ul_r~+1~
{ASSIGN}ur_r~{VARIABLE}ur_r~+1~
{IF}{VARIABLE}ul_r~>{VARIABLE}ll_r~-2~
{ASSIGN}ul_r~{VARIABLE}ll_r~-2~
{ASSIGN}ur_r~{VARIABLE}ul_r~~
{END IF}
{CALL}write~
{END IF}
{IF}"{VARIABLE}key~"="{Enter}"~
{CALL}action~
{END IF}
{IF}"{VARIABLE}key~"="{Exit}"~
{GO}exit~
{END IF}
{GO}loop_top~

This segment is one of four routines for adjusting the margins (shown is the macro code for adjusting the top margin). Pressing the up or down cursor keys moves the margins up or down on the page. Pressing [Enter] accepts the changes, and returns you to the main menu where you can make additional margin changes. Pressing [F7] accepts the changes, formats the document with the new margins you've created, and exits the macro.

{ASSIGN}top~{VARIABLE}ul_r~/2~
{ASSIGN}top_dec~{VARIABLE}ul_r~%2~
{IF}{VARIABLE}top_dec~=1~
{ASSIGN}top_dec~5~
{END IF}

The MARGSET.WPM macro converts the screen coordinates used to display the margins to actual margin settings, in inches. The macro calculates the margins in half-inch increments, adding the decimal point as required.

 

HEADERS AND FOOTERS

By now, you probably know that a header is text that repeats on at the top of every page and that a footer is text that repeats at the bottom of every page. WordPerfect further allows you to define any number of headers or footers per document (you can easily switch between two pre-defined headers/footers), and apply them to every page, or every odd or even page.

If you are a regular user of headers or footers, you'll find this collection of macros useful for automatically defining them, turning them off an off, and more.


Defining a New Header or Footer

HEADER.WPM nearly automates the steps of defining a new header. Executing the macro tells WordPerfect you want to define a new header. The macro pauses to let you enter the definition of the header in the header definition window. The moment you press [F7] to exit, the remainder of the macro starts and brings you all the way back to the document. The code for the newly defined header is automatically inserted in the text.


HEADER.WPM (provided on the Applications Disk)
1.  {DISPLAY OFF}
2.  {Format}P
3.  H
4.  A
5.  P
    {DISPLAY ON} 
6.  {ASSIGN}0~~
    {LABEL}loop~
    {VAR 0}   
    {LOOK}0~
    {IF}"{VAR 0}"="{Exit}"~ 
      {DISPLAY OFF}
      {Exit}{Enter}{Enter}
      {DISPLAY ON}
    {ELSE}
      {GO}loop~
    {END IF}

You can use the macro as a basis for defining new footers, as well. You may define header/footer "B" instead of "A," and choose to apply it every page, odd pages, or even pages.

 

Turning a Header or Footer Off

This macro turns a header or footer off. This example is written for Header A; rewrite it to turn Header B or Footer A/B off. You can create this macro from the keyboard, as shown here, or from inside the macro editing window.


OFFAHEAD.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl] -[F10] Starts macro definition.
2. offahead [Enter] Names macro "OFFAHEAD.WPM," for header A off.
3. Turn header A off
[Enter]
Describes macro.
4. [Shift]-[F8] Chooses Format menu.
5. P H A Selects Page, Header, and Header A options.
6. D Selects Discontinue option.
7. [Enter] [Enter] Returns to document.
8. [Ctrl]-[F10] Ends macro definition.

Note that this macro, when used, turns the A header off after it has been on.


Suppressing a Header or Footer

Sometimes, you may want to turn a header or footer off for a single page, and not worry about turning it back on after the page is over. Here are four macros, one each for Header A/B and Footer A/B, for doing the job quickly and easily.


SUPAHEAD.WPM -- Suppress Header A (provided on the Applications Disk)

{DISPLAY OFF}
{Format}PUHY{Enter}
{Enter}{Enter}
{DISPLAY ON}


SUPBHEAD.WPM -- Suppress Header B (provided on the Applications Disk)

{DISPLAY OFF}
{Format}PUEY{Enter} {Enter}{Enter}
{DISPLAY ON}


SUPAFOOT.WPM -- Suppress Footer A (provided on the Applications Disk)

{DISPLAY OFF}
{Format}PUFY{Enter}
{Enter}{Enter}
{DISPLAY ON}


SUPBFOOT.WPM -- Suppress Footer B (provided on the Applications Disk)

{DISPLAY OFF}
{Format}PUOY{Enter}
{Enter}{Enter}
{DISPLAY ON}


Constructing Header/Footer Libraries

If you use it often enough, you may want to save the definition for a header or footer once you have created it. You can save the definition as a macro, style, or document.

To call up the header or footer, run the macro, choose the style, or retrieve the document. It's that simple. For ease of use, develop a naming strategy so that you can readily identify the header and footer files on the disk. For instance:

 

Using Header and Footer Prefixes

If you find that you mix and match the text for headers and footers -- sometimes the text is for a header and sometimes it's for a footer, you can construct a macro "prefix" that starts either a header or footer for the definition that follows. The definition itself contains only formats and text for the header or footer. Be sure to leave out the the codes for actually starting a header/footer. The system works when storing headers and footers as macros, styles, or documents. The following example shows how it can be used with header macros.

First, create the "prefix" macro.


HEAD.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Format}PHAP
{TEXT}0~~
{CHAIN}{VAR 0}~

Next, create the actual header definition macro. This example prints "This is a test..." in the header. Call this macro HEADTEST. Include the the macro the codes necessary to exit the header editing screen, such as {Exit}{Enter}{Enter}.

To use the header prefix with the HEADTEST header definition, press [Alt]-[F10] to call up a macro, then type HEAD. Instead of pressing [Enter], just tap on the [Spacebar]. That does the same thing as pressing the [Enter] key -- it starts macro execution -- but is more intuitive when entering the prefix and definition macros. The HEAD.WPM prefix macro will run and stop at the {TEXT} instruction. Since no message is displayed, the screen will remain blank. Now enter HEADTEST as the definition macro you want to use. Press [Enter] when you are through and the header definition is complete. As shown, the HEAD.WPM macro starts a Header A definition and applies the header to every page. Because the HEADTEST.WPM header macro contains only the actual definition of the header and not all the steps for creating the header from scratch, you can use it to also make a footer. The same is true is you wish to apply the HEADTEST.WPM definition to Header or Footer B, and to apply the header/footer to just odd or even numbered pages.

You can create other header/footer prefixes to suit your needs. Here are some examples.


To define Footer A on every page:

{DISPLAY OFF}
{Format}PFBP
{TEXT}0~~
{CHAIN}{VAR 0}~

Name the macro FOOT.WPM.


To define Footer B, on for even pages only:

{DISPLAY OFF}
{Format}PFBV
{TEXT}0~~
{CHAIN}{VAR 0}~

Name the macro FOOTAEVN.WPM.


To define Head B, on for odd pages only:

{DISPLAY OFF}
{Format}PHBO
{TEXT}0~~
{CHAIN}{VAR 0}~

Name the macro HEADBODD.WPM.


Header/Footer Selector Macro

The Applications Disk provides a handy header/footer selector macro (it won't be detailed here step-by-step because it uses macro programming techniques discussed in previous chapters). It is designed to make header and footer creation easier, working on the assumption that you will probably want to create a A header or footer. You have your choice of creating the header for all, even, or odd pages. If you need to edit a header or footer, or discontinue it, you can use one of the macros detailed earlier.


HFSELECT.WPM

{CHAR}key~{^]}1 H{^\}eader  {^]}2 F{^\}ooter  
{^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~head~
1~head~  H~head~  h~head~
2~foot~  F~foot~  f~foot~ ~
{QUIT}

{LABEL}head~
{CALL}setup~
{DISPLAY OFF}
{Format}PHA
{VARIABLE}key~
{PAUSE KEY}{Exit}~
{GO}quit~

{LABEL}foot~
{CALL}setup~
{DISPLAY OFF}
{Format}PFA
{VARIABLE}key~
{PAUSE KEY}{Exit}~
{GO}quit~

{LABEL}setup~
{CHAR}key~
{^]}1{^\} Every {^]}P{^\}age  
{^]}2 O{^\}dd Pages  {^]}3{^\} E{^]}v{^\}en Pages  
{^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~every~ 1~every~ P~every~ p~every~
2~off~   O~odd~   o~odd~
3~even~  V~even~  v~even~
~
{GO}setup~

{LABEL}every~
{ASSIGN}key~P~
{RETURN}
{LABEL}odd~
{ASSIGN}key~O~
{RETURN}
{LABEL}even~
{ASSIGN}key~V~
{RETURN}

{LABEL}quit~
{DISPLAY OFF}
{Exit}{Exit}

To use the macro, select Header or Footer (pressing the [Enter] key automatically selects the header option), then choose Every Page, Odd Pages, or Even Pages. The macro places you in the header/footer window. When you're done writing, press Exit to go back to the main editing screen.

Note that the macro uses the {PAUSE KEY} command to sense when you've pressed the Exit ([F7]) key. If you choose a WordPerfect function key (like Format), be sure to use the [Enter]key to exit the various menus. Should you press the Exit key, the macro will interpret is as the signal that you are done writing the header or footer, and will try to get back to the main editing screen.

 

FOOTNOTES AND ENDNOTES

WordPerfect provides many options for setting up footnotes and endnotes in documents. That means extra keystrokes to define even one footnote or endnote. If all you need to do is enter standard footnotes and endnotes, there two macros will greatly speed up the process.


Creating Footnotes and Endnotes

Although the macros are called FOOTNOTE.WPM and AND ENDNOTE.WPM on the Supplement Disk, for ease of use you should rename them with an [Alt]-letter key combination. These are basic macros that you may want to to embellish and edit, as you see fit.


FOOTNOTE.WPM (provided on the Applications Disk)

{Footnote}FC
{Tab}


ENDNOTE.WPM (provided on the Applications Disk)

{Footnote}EC
{Tab}

When the macros finish, you are left in the footnote/endnote editing window. Write the note and press the Exit key to go back to the document.


Restarting Footnote/Endnote Numbering

When stringing many documents together into a book or articles series, it's often desirable to continue the endnote and footnote numbering of previous documents. WordPerfect allows you to start note numbering at any point. These two macros eliminate a few of the keystrokes. After executing the macro, enter the new note number and press [Enter].


FOOTNUM.WPM (provided on the Applications Disk)

{Footnote}
FN


ENDNUM.WPM (provided on the Applications Disk)

{Footnote}
EN


Placing Endnote Codes

You may specify any place in your document for endnotes. When WordPerfect encounters the endnote placement code, [Endnote Placement], it unloads all of the endnotes it has accumulated since the beginning of the document or since the last endnote placement code. Here's a macro that not only places the code but generates forces WordPerfect to calculate the amount of space needed by the endnotes.


ENDPLACE.WPM (provided on the Applications Disk)

{Footnote}PN
{Mark Text}GGY


Building Elaborate Footnote and Endnote Styles

WordPerfect allows you to control just about every aspect of the appearance of footnotes and endnotes. The Footnote/Endnote Options menu allows you to change among other things the style for the note number in the text and in the note, the line separator between text and notes, the placement of footnotes on the page, and more.

While you could encode these Option settings in a macro, a better place is in a style that you insert at the top of the document, or wherever you want to specify formats for the footnotes and endnotes. If you regularly use the style, include it in the Style Library so that every new WordPerfect document has easy access to it.

 

HOLLYWOOD-STYLE SCRIPT FORMATS

Movie studios and producers expect scripts for television and movies to be in a specific format. Writing scripts on a word processor is actually harder than writing them on a typewriter. If you are not careful, choosing the wrong formatting strategy with the word processor makes editing the script extremely difficult and time consuming.

There are a number of stand-alone script-writing word processors on the market; WordPerfect is not one of them. It lacks the special features most desired by studio and professional script typists, but WordPerfect is perfectly adept for use by writers, whose main concern is getting the action and dialog on paper and in the proper format. Thanks to WordPerfect macros, writing and editing scripts is made much simpler than it used to be.

To make the use of script-writing macros easier, we've combined them in a single keyboard layout, provided on the Applications Disk. This layout is called SCRIPT.WPK. To use it, it must be in your default macros directory (or in your WordPerfect default directory if you haven't set a macros directory with the Location of Files command). Alt-letter keys are used to access the various script macros within the keyboard layout.


Script Formats

At their basic level, scripts can be divided into two discrete formats: action and dialog. The action format places the text between two wide margins on either side of the page. You can actually use WordPerfect's default format settings for the action sections of your script. That leaves setting up special margins and tab settings just for the dialog sections.

Dialog sections contain the name of the character, an optional description of the delivery of the line (almost always written as an adverb), and the dialog text. The character name can be indented a certain number of spaces from the left margin, or centered between the margins.


Setting Script Formats Using Macros

While there are many ways to format scripts in WordPerfect, macros present a fast and efficient approach. The main function of the script-writing macro is to change the margins between dialog and action parts. You can also use macros to automatically provide common text elements, such as FADE OUT, CUT TO:, and INT. -- DAY. You can also use macros to automatically prevent the dialog text from becoming separated from the character name at a page break. This minimizes the time you must spend reviewing the manuscript prior to printing.


Basic Dialog Macro

The dialog macro uses standard formatting, applicable to both action and dialog sections

You can set the format as a style and apply it at the beginning of the script, or you can embed the codes in a script template document. Retrieve the template document to start each new script, then save it under a different name. Or, you can create a macro that runs through the formatting changes. This is the approach we've taken in our macro script-writing system.

The SCRIPT.WPK keyboard layout includes seven macros:

Start first with the Alt-F (for Format) macro. This sets up the margins and tabs. You can now begin typing.

IMPORTANT NOTE: The block protection macro works by searching for a [Center] code, which it expects to find ONLY for character names. If you don't use centered character names, you'll need to devise a different way to search for them. Once found, the macro turns block on, and highlights the first two lines. If the second line ends with a right parenthesis, the macro blocks one additional line (for a total of three lines), then turns block protection on. When you write parenthetical stage instructions, be sure to press the [Enter] key immediately after the ) character. Those three lines will always appear together on a page, and won't be broken at a page break. If the second line ends with a hard return, only those lines are protected. In all other instances, the macro block protects the first three lines -- character name, and two lines of the dialog.

 

MACROS FOR BUILDING A TABLE OF CONTENTS AND INDEX

The biggest job in building a table of contents or index in WordPerfect is marking the text you wanted included in the list. As you might have guessed, macros make the process a lot easier.


Marking for a Table of Contents

Text for a table of contents is usually composed of the headings and sub-headings in your document. WordPerfect lets you assign different levels to table of contents entries. This macro allows you to assign the level you want. If you plan on setting all entries at the same level, you can incorporate the appropriate keystrokes in the macro.


MARKTOC.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. marktoc
[Enter]
Names macro.
3. Mark table of contents [Enter] Describes macro.
4. [Alt]-[F4] Starts block.
5. [End] Moves cursor to the end of the line.
6. [Alt]-[F5] Chooses Mark Text menu.
7. D C Selects Mark ToC option.
8. [Ctrl]-[F10] Ends macro definition.

To use the macro, first position the cursor in front of the heading you want to mark. Start the macro, then enter the desired table of contents level number (press numbers 1 to 5). After pressing a number, WordPerfect returns to the main document, where you can mark another entry for the table of contents or generate the table. WordPerfect adds the proper table of contents mark code.

Remember that you can't actually generate the table of contents without first defining it. Refer to the WordPerfect manual on how to define the table of contents. If you create lots of documents each with a table of contents, you wish to automate this process by turning it into a GENERATE.WPM generates the table of contents (after it has been defined and all the entries marked). The macro can also be used to generate an index, list, and table of authorities after these have been defined and marked.


GENERATE.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. generate [Enter] Names macro.
3. Generate list, etc. Describes macro.
[Enter]
Describes macro.
4. [Alt]-[F5] Chooses Mark Text menu.
5. G G Y Selects Generate option; answers Yes to prompt.
6. [Ctrl]-[F10] Ends macro definition.

 

Marking an Index

The process of marking text for an index is similar to that of marking text for a table of contents. The biggest difference is that you mark only single words or phrases for an index, not the entire line. The macro that follows automatically marks the word closest to the cursor. It uses WordPerfect's default suggestions for index headings and sub-headings.

While this macro may not always mark the words the way you want for the index, it will work in your favor over 80 percent of the time. You can always go back and remark a word or a phrase manually if the index entry doesn't suit you.


MARKIND.WPM (provided on the Applications Disk)

Key Sequence What it Does
1. [Ctrl]-[F10] Starts macro definition.
2. markind
[Enter]
Names macro.
3. Mark index
[Enter]
Describes macro.
4. [Alt]-[F5] Chooses Mark Text menu.
5. I Selects Mark Index option.
6. [Enter] [Enter] Accepts suggestions for index heading and sub-heading.
7. [Ctrl]-[F10] Ends macro definition.

Be sure to define the index at the end of the document before attempting to generate it.


Enhanced Index Marking Macros

Suppose you already know what word you want to include in the index but don't want to search through the entire document one by one and find all the occurrences of the indexed words. While you could generate a concordance for such a job, the concordance only lists the occurrence of each word, and not how the word was used in the text.

Here's an example: Using a concordance file to indicate all the occurrences of the word "clone" in a document or book only lists those pages that contain "clone." If you desire an effective index, you'll need to describe how "clone" is used. On one page, the word may refer to IBM PC compatibility on a hardware level, and on another page it may refer to compatibility on a software level.

The macro presented here prompts you to enter the word or phrase you want to look for, then automatically marks it for indexing. This macro lets you enter another word or phrase for both the index heading and sub-heading.


INDEXWRD.WPM (provided on the Applications Disk)

1. {TEXT}0~Enter the text you want to index  ~
   {LABEL}start~
2. {Search}{VAR 0}{Search}
   {Mark Text}I
3. {ASSIGN}2~0~
   {ASSIGN}1~~
   {LABEL}loop~
   {VAR 1}
   {LOOK}1~
   {IF}"{VAR 1}"="{Enter}"~
     {GO}count~
   {ELSE}
     {GO}loop~
   {END IF}
4. {LABEL}count~
   {ASSIGN}2~{VAR 2}+1~
   {IF}{VAR 2}=2~
      {GO}doanother~
   {ELSE}
      {GO}loop~
   {END IF}
5. {LABEL}doanother~
   {CHAR}3~{^\}Do another of same word?  
   {^]}1 Y{^\}es   {^]}2 N{^\}o  {^]}1{^\}{Left}~
   {CASE}{VAR 3}~
     {Enter}~yes~
     1~yes~   Y~yes    y~yes~
     2~no~    N~no~    n~no~
     ~
   {GO}doanother~
   {LABEL}yes~
   {Search}
   {GO}start~
   {LABEL}no~
   {Enter}
   {QUIT}

Use the following macro if you suspect that the word or phrase occurs many times throughout a document, and don't need to indicate a different heading or sub-heading for each instance. The macro is easier to use than a concordance file.


INDEXER.WPM (provided on the Applications Disk)

{TEXT}0~Enter the text you want to index  ~
{Search}{VAR 0}{Search}
{Mark Text}I

{ASSIGN}2~0~
{ASSIGN}1~~
{LABEL}loop~
{VAR 1}
{LOOK}1~
{IF}"{VAR 1}"="{Enter}"~
{GO}count~
{ELSE}
{GO}loop~
{END IF}

{LABEL}count~
{ASSIGN}2~{VAR 2}+1~
{IF}{VAR 2}=2~
{GO}nextround~
{ELSE}
{GO}loop~
{END IF}

{LABEL}nextround~
{Enter}
{DISPLAY OFF}
{Search}{VAR 0}{Search}
{Mark Text}I
{Enter}
{GO}nextround~

 

MACROS FOR WRITING AND EDITING

Macros can be used for just about any text writing and editing task. The type of manuscripts you create, and your work habits, will largely dictate the kinds of macros that will be of most use for you. Here is a collection of short macros you can create to help your writing and editing go faster.

For ease of use, the following macros are provided in the MSCRIPT.WPK keyboard layout, provided on the Applications disk. Most of the MSCRIPT macros are compatible with WordPerfect 5.0. The programming of these macros won't be detailed here, as most of the macros are keyboard recorded and contain only standard WordPerfect functions.


General Purpose

Alt-Z
Undos (restores) last deletion
Alt-X
Cuts selected text Start macro, move cursor to end of block, and press [Enter]
Alt-C
Copies selected textSame as Alt-X
Alt-V
Pastes text in clipboard
Alt-Q
Approximates original (4.2) line draw function (no arrows on lines)
Alt-W
Clears {INPUT} or {STATUS PROMPT} that may remain on screen after a macro has finished.

Delete Text

Alt-S
Deletes current sentence ("current" is sentence under cursor)
Alt-L
Deletes current line
Alt-P
Deletes current paragraph

 

Copy Text

Alt-E
Copies current sentence ("current" is sentence under cursor)
Alt-I
Copies current line
Alt-A
Copies current paragraph

 

Modify Attributes

Alt-B
Bold already written textStart macro, move cursor to end of block, and press [Enter]
Alt-U
Underline already writtenSame as Alt-B text
Alt-F
Change font size Select new font or change font for already written text
Alt-Y
Change the font style Same as Alt-F
Alt-N
Center line Choose new line or already written line
Alt-D
Create indents Choose handing indent or list indent

 

Shortcut Keys

Alt-G
Move to column on left
Alt-H
Move to column on right
Alt-K
Calculate Calculates math and table formulas
Alt-M
Finds and displays next Choose footnote or Footnote or endnote endnote
Alt-T
List files on floppy. Choose drive A: or B:

 

View WordPerfect State

Alt-O
Displays all current state When used in a menu, variables (as reported bypress F1 several {STATE} macro command) times to clear screen
Alt--
View all current font When used in a menu, attributes; press F1 several times to clear the screen

 

MACROS FOR DOCUMENT CONVERSION

If you have ever imported text from another IBM PC, you know that the process isn't 100 percent foolproof. Even with WordPerfect's CONVERT program, a number of files are imported with odd characters or hard returns within paragraphs when there would be soft returns. A set of macros can greatly ease the trouble importing text to WordPerfect. By the same token, you can easily develop macros for preparing files for exporting from WordPerfect.

One of the most common problems with imported text is that they lack often soft carriage returns within the paragraphs. If you want to edit the text in WordPerfect, you'll need to convert the hard hard carriage returns in each paragraph so that WordPerfect will be able to properly word-wrap at the end of each line. Of course, you need to keep the hard return that marks the end of each paragraph.

WordPerfect has an option in the Text In/Out menu where you can choose to import an ASCII (or DOS) text file and automatically convert line feed/carriage return characters to WordPerfect soft returns. The feature doesn't work with with all imported files so you'll need to change the return characters manually yourself. The exact way you do it will depend on the format of the text as well as the the original word processor that created it. Note that even a super-sophisticated macro may not be able to fully reformat an imported file. You may still need to go through the document and make minor corrections.


Revealing Hard Carriage Returns

You can always see the [HRt] code in a document by choosing Reveal Codes, but your view of the document is cut in half. An easier way to view hard returns is to change the paragraph mark character. Normally, the paragraph character is not visible, but you can turn it into any other character from within the Setup menu.

Key Sequence What it Does
1. [Shift]-[F1] Selects Setup menu.
2. D E H Chooses Display and Paragraph Character options.
3. [Ctrl]-2 4,5 Enters paragraph character using compose key (you can select any other character from WordPerfect's character sets as long as your computer will display it).
4. [Enter] [Enter] Exits Setup menu.

Now the document is filled with paragraph symbols. Converting the document, either manually or with the aid of macros, is now much easier. You can revert to regular (invisible) hard returns, repeat the process by press [Enter] as the paragraph symbol. You may wish to encode the turn-on and turn-off paragraph symbols as macros. An all-in-one macro is included on the Applications disk. PARASYM.WPM turns the paragraph symbol on and off, following your command.


PARASYM.WPM (provided on the Applications Disk)

{CHAR}key~{^\}Paragraph symbol: {^]}1 O{^\}n  
{^]}2{^\} O{^]}f{^\}f  {^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~on~
1~on~ O~on~ o~on~
2~off~F~off~f~off~
~
{QUIT}

{LABEL}on~
{DISPLAY OFF}
{Setup}DEH&&P&&
{Exit}
{QUIT}
{LABEL}off~
{DISPLAY OFF}
{Setup}DEH{Enter}
{Exit}
{QUIT}


Converting Standard Manuscript Documents

While there really isn't any such thing as a "standard manuscript," the term is used here to describe the common double-space manuscript format used in term papers, magazine articles, novels, etc. The first line of each paragraph is typically indented five to 10 characters from the left margin.

But by analyzing the basic format of the manuscript, it's possible to arrive at a means of easily removing the extra hard carriage returns. To convert the document, you want to accomplish these two goals:

You can't remove all the hard returns in a document or you loose the paragraph divisions. Luckily, the manuscript format provides some help. The start of each new paragraph begins with empty spaces, which represent a tab. You can use the tab as a means to identify paragraphs. Once the paragraphs are identified, the extra returns can be removed.

These two functions are built into the IMPORT.WPM macro described here. The macro is divided into two functional parts: a space-to-tab converter and a hard return remover.


IMPORT.WPM (provided on the Applications Disk)

{ON NOT FOUND}{GO}not_found~~
{CHAR}key~{^]}1 C{^\}onvert Space-to-Tab  
{^]}2 R{^\}emove Hard Returns  {^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~conv~
1~conv~  C~conv~  c~conv~
2~rem~   R~rem~   r~rem~
~
{QUIT}

{LABEL}conv~
{ASSIGN}function~Space-to-Tab~
{ASSIGN}space~~
{TEXT}key~Set number of spaces to convert  ~
{FOR}set_space~1~{VARIABLE}key~~1~
{ASSIGN}space~{VARIABLE}space~ ~
{END FOR}
{Replace}n{VARIABLE}space~{Search}
{Tab}{Search}
{GO}not_found~
{LABEL}rem~
{ASSIGN}repeat~rem~
{ASSIGN}function~Hard return removal~
{Search}{Tab}{Search}
{Block}
{Search}{Tab}{Search}
{Left}{Left}{Left}
{Replace}n{Enter}{Search}{Search}
{GO}{VARIABLE}rem~~
{LABEL}not_found~
{BELL}
{CHAR}key~{VARIABLE}function~ conversion is 
complete.  Press a key  ~
{ASSIGN}repeat~~
{ASSIGN}function~~
{ASSIGN}set_space~~
{ASSIGN}space~~

The space-to-tab routine ("conv") converts any number of spaces to tabs. You are prompted for the number of spaces you want to exchange for tabs. The macro uses a {FOR} next to build a variable, named space, with the specific number of space characters you indicate.

The "rem" routine searches for a [Tab] code (which marks the start of a paragraph), then turns block on to select the text to the next [Tab] code. The three {Left} instructions back up the cursor so that the last hard return in the paragraph isn't removed. You may need to add or remove {Left} instructions to suit the needs of your converted manuscripts.

The macro repeats itself when it reaches the end. Note that the macro may be caught in an endless loop if there are two or more [Tab] codes adjacent to one another. If this is the case in your document, skip over the codes or temporarily remove them.


Block Removal of Hard Carriage Returns

Another approach to converting standard documents is provided in the next macro, TOSOFT1.WPM. Here, you manually select the entire paragraph except for the last hard carriage return. WordPerfect changes the hard returns to soft returns, but only within the blocked area.


TOSOFT1.WPM

{CANCEL OFF}
{Block}
{INPUT}Move cursor to end; Enter when finished  ~
{Replace}n{Enter}
{Search}{Search}


Alternative Hard Carriage Return Remover

Some documents may have extra spaces before the hard carriage returns. These should be removed before converting the hard returns to soft returns. Here is a suitable macro for this purpose:

TOSOFT2.WPM

{CANCEL OFF}
&&{Block}
{INPUT}Move cursor to end; Enter when finished  ~
{Replace}n {Enter}{Search}{Enter}{Search}
{Search Left}{Enter}{Search}{End}{Left}
{Block}{Search Left}&&{Search}
{Replace}n{Enter}{Search}{Del to EOL}{Search}
{Search Left}&&{Search}
{Backspace}{Backspace}

This macro is the same as the previous one except that it first removes one extra space before each hard return and replaces it just with a hard return. The macro then searches backwards to find the "&&" characters originally left to mark the beginning of the block. The paragraph is reselected and the macro now replaces all the hard returns with nothing (the {Del to EOL} instructions assures that the Replace With: string is empty). Finally, the macro backs up once more and deletes the "&&" marker characters.


Converting Secondary Merge Files to Regular Documents

A secondary merge file contains {End Field} codes to designate the end of each field and {End Record} codes to designate the end of each record. Many IBM PC programs, particularly electronic spreadsheet applications such as Lotus 1-2-3 and Microsoft Excel, generally expect field/record information to be in column/line organization. Each line denotes a record and each column, delimited by a comma or tab, denotes a field.

Although the CONVERT program included with WordPerfect permits you to export secondary merge files to comma and tab delimited ASCII files, you may wish to have more control over the conversion process. You can readily change WordPerfect secondary merge files to standard delimited text documents with a macro.

The STRIPPER.WPM macro converts secondary files to column/line format, ready for exporting to a program like 1-2-3 or Excel (save these converted documents in DOS format using the Text In/Out key, not in WordPerfect format using the standard Save key). The STRIPPER macro was used to convert the secondary files to delimited text.

This macro assumes that:

You have your choice of delimiting the fields with commas or tabs, and for removing the {End Record} codes (the hard page codes are left; these can be readily changes to hard returns if required).


STRIPPER.WPM (provided on the Applications Disk)

{CHAR}key~{^\}Strip to: {^]}1 T{^\}ab  {^]}2 C{^\}ommas  
{^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~tab~
1~tab~   T~tab~   t~tab~
2~comma~ C~comma~ c~comma~
~
{QUIT}

{LABEL}tab~
{ASSIGN}strip~{Tab}~
{GO}cont~
{LABEL}comma~
{ASSIGN}strip~,~
{LABEL}cont~
{CHAR}key~{^\}Delete End Record Codes 
({^]}Y{^\}es/{^]}N{^\}o)?  {^]}Y{^\}{Left}~
{IF}"{VARIABLE}key~"="Y"|"{VARIABLE}key~"="y"
|"{VARIABLE}key~"="{Enter}"~
{ASSIGN}endRec~{Merge Codes}E{Search}~
{ELSE}
{ASSIGN}endRec~{Del to EOL}~
{END IF}
{ON NOT FOUND}{GO}stripper~~

{Home}{Home}{Up}
{Replace}n{VARIABLE}endRec~{Search}

{LABEL}stripper~
{Home}{Home}{Up}
{Replace}n{End Field}{Enter}
{Search}{VARIABLE}strip~{Search}
{DISPLAY ON}
{ASSIGN}endRec~~
{ASSIGN}strip~~
{QUIT}


Converting Delimited Files to Secondary Merge Files

The following macro converts tab and comma delimited files into standard secondary merge document format, adding a {End Field} codes to separate each field (the {End Record} code is not added). To use the macro, indicate whether the source document uses tab or comma delimiters.


TOMERGE.WPM (provided on the Applications Disk)

{CHAR}key~{^\}Strip: {^]}1 T{^\}ab  {^]}2 C{^\}ommas  
{^]}1{^\}{Left}~
{CASE}{VARIABLE}key~~
{Enter}~tab~
1~tab~   T~tab~   t~tab~
2~comma~ C~comma~ c~comma~
~
{QUIT}

{LABEL}tab~
{DISPLAY OFF}
{Home}{Home}{Home}{Up}
{Replace}n{Tab}
{Search}{^R}{Enter}{Search}
{DISPLAY ON}
{Merge/Sort}C
{QUIT}
{LABEL}comma~
{DISPLAY OFF}
{Home}{Home}{Home}{Up}
{Replace}n,
{Search}{^R}{Enter}{Search}
{DISPLAY ON}
{Merge/Sort}C
{QUIT}

If you'd like to convert a tab delimited file to a full WordPerfect merge-compatible document, complete with {End Field} and {End Record} codes, use CONVERT.WPM, shown here. The macro expects fairly standard formatting:

 

CONVERT.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Home}{Home}{Up}
{Replace}n{Enter}{Search}{^R}{Enter}{^E}{HPg}{Search}
{Home}{Home}{Up}
{Replace}n{Tab}{Search}{^R}{Enter}{Search}
{Merge/Sort}C
{DISPLAY ON}

---

 Top Contents

WordPerfect 5.1 Macros and Templates
Electronic Edition
Copyright 1990, 1997, Gordon McComb.  All Rights Reserved.
First published by Bantam Electronic Publishing, 1990.
http://www.gmccomb.com/