Chapter 17

MACRO POTPOURRI

Ponder the situation long enough and you can construct a macro for just about anything. This chapter is devoted to those macros that don't squarely fit into any particular category, but are nonetheless functional and practical. A few of the macros have nothing to do with word processing applications, but show that WordPerfect macros can be programmed to meet any challenge.

In this chapter you'll find:

 

NOTE PAD

How many times have you needed to jot down a note or memo to yourself, but you were in the middle of writing a document with WordPerfect. You could invest in a ram-resident notepad program, like Sidekick!, but why spend the money if you can create the same thing for free with WordPerfect. All it takes is a macro.

The NOTEPAD.WPM macro described here lets you write a note while working with WordPerfect. It creates the note in an empty footnote document, so your work is not touched. The macro appends the note to a file called NOTES.TXT. You can keep writing notes and the macro will keep adding them to the end of this file. Whenever you wish you can print the file and throw it away. The next time you use NOTEPAD.WPM the NOTES.TXT file is created from scratch, and the cycle repeats itself.

To use this macro, you must be at the WordPerfect main document screen (either Doc 1 or Doc 2).


NOTEPAD.WPM (provided on the Applications Disk)

1.  {DISPLAY OFF}
    {Footnote}FC{Backspace}y
    {Enter}{Enter}
2.  DATE/TIME:
    {Tab}
    {Date/Outline}T / 
    {Date/Outline}F8:90{Enter}T
    {Enter}{Enter}
3.  SUBJECT:
    {Tab}
    {DISPLAY ON}
    {STATUS PROMPT}Enter subject; Enter when done  ~
    {PAUSE}
    {Enter}{Enter}{Enter}
4.  TEXT:
    {Tab}
    {STATUS PROMPT}Write the memo text here; Exit 
    when done  ~
    {CANCEL OFF}
    {PAUSE KEY}{Exit}~
    {STATUS PROMPT}~
5.  {DISPLAY OFF}
    {Enter}{Enter}{Enter}
    -----
    {Block}{Search Left}DATE/TIME:{Search} {Home}{Left}{Left}{Left}
    {Block Append}
    NOTES.TXT{Enter}
    {Enter}{Exit}{Backspace}y
6.  {Setup}ID{Exit}{Exit}

 

ELECTRONIC WHILE-YOU-WERE-OUT PAD

R-r-r-r-iiinnng! You answer the phone but it's not for you. The person the caller wants to speak with is out of the office, so you're asked to take a message. No where is that pencil and paper? There's no need to search your desk for elusive writing instruments: let WordPerfect record the phone message for you.

The following macro uses the {TEXT} command to prompt you for the message notes. Enter each note and press the [Enter] key. You can leave any note blank just by pressing the [Enter]key without writing any text. After you've filled in the blanks, the macro displays the message on the screen, and asks you if the information is correct. If it is, press Y, and the message is stored in a FONEPAD.TXT document (if the document doesn't already exists WordPerfect will create it). Phone messages are appended to the FONEPAD.TXT file as you write them. When you've collected a number of messages, print them out and erase the FONEPAD.TXT file. The next messages you take will be entered into a new document.


FONEPAD.WPM (provided on the Applications Disk)

1.  {ON CANCEL}{GO}cancel~~
    {DISPLAY OFF}
    {Footnote}FC{Backspace}y
2.  {LABEL}loop~
    {Home}{Home}{Up}
    {Del to EOP}y
    {TEXT}key1~Who is the call for?  ~
    {TEXT}key2~What is the name of the person calling?  ~
    {TEXT}key3~From what company/organization?  ~
    {TEXT}key4~Return phone number?  ~ {TEXT}key5~{Up}What is the
    message (up to 120 chars.)?{Enter}~
    {TEXT}key6~{Up}{Del to EOL}{Down}
    Will call back/please call/other comments?  ~
3.  Date: {Date/Outline}T          
    Time: {Date/Outline}F8:90{Enter}T{Enter}
4.  {DISPLAY OFF}
    {DISPLAY ON}
    To: {VARIABLE}key1~{Enter}
    Person calling: {VARIABLE}key2~{Enter}
    From: {VARIABLE}key3~{Enter}
    Phone: {VARIABLE}key4~{Enter}
    Message: {VARIABLE}key5~{Enter}
    Notes: {VARIABLE}key5~{Enter}
    {Enter}{Enter}
5.  {LABEL}okay~
    {CHAR}key~{^\}Is everything correct 
    ({^]}Y{^\}es/{^]}N{^\}o)  {^]}Y{^\}{Left}~
    {CASE}{VARIABLE}key~~
      {Enter}~rec~
      Y~rec~   y~rec~
      N~loop~  n~loop~
      ~
    {GO}okay~
6.  {LABEL}rec~
    {DISPLAY OFF} {Home}{Home}{Up}
    {Block}{Home}{Down}
    {Move}BA fonepad.txt{Enter}
    {Exit}{Backspace}y
    {Setup}ID{Exit}{Exit}
    {QUIT}
7.  {LABEL}cancel~
    {DISPLAY OFF}
    {Exit}{Backspace}y

Another approach to recording a phone message is provided in PHONE.WPM. This is a more refined macro but uses much of the same techniques as FONEPAD.WPM. The main difference is that you can choose to enter specific items in the phone message, such as company, phone number, and message. Press a number you can enter the information for that line item. You can easily re-enter information by selecting that item again. PHONE.WPM is a good example of a macro you can readily modify to suit your requirements. You can modify the macro to ask for and store any type of information.

To use PHONE.WPM:

  1. Start the macro in the usual manner.
  2. Press a number (from 1 to 6) to enter a message item. For example, to enter the name of the caller, press 1. As a shortcut, the macro keeps track of the last message item you entered, and makes the next line the default. Press [Enter] to select the default (the default line number is shown above the flashing cursor).
  3. Write the message text, and press [Enter] when you're done.
  4. When you're finished entering the message text, press 6 to log the note.
  5. Indicate if you want to use the standard PHONELOG.TXT file. Answering Y (also y or [Enter]) automatically saves the file; if you answer No, you are asked to provide the name of the log file you want to use.

 

PHONE.WPM (provided on the Applications Disk)

1.  {ON ERROR}~
    {ON CANCEL}{GO}cancel~~
    {CALL}clear~
    {ASSIGN}current~1~
2.  {LABEL}menu~
    {CHAR}key~{Del to EOP}
    {^\}Telephone Log{Enter}{Enter}
    {^]}1 N{^\}ame:   {VARIABLE}key1~{Enter}{Enter}
    {^]}2 C{^\}ompany:  {VARIABLE}key2~{Enter}{Enter}
    {^]}3 P{^\}hone:   {VARIABLE}key3~{Enter}{Enter}
    {^]}4 M{^\}essage:  {VARIABLE}key4~{Enter}{Enter}
    {^]}5 S{^\}pecial Instructions:  {VARIABLE}key5~
    {Enter}{Enter}
    {^]}6 L{^\}og this call  {Enter}{Enter}{Enter} Enter choice  
    {^]}{VARIABLE}current~{^\}{Left}~
3.  {CASE}{VARIABLE}key~~
    {Enter}~{VARIABLE}current~~
      1~1~  N~1~  n~1~
      2~2~  C~2~  c~2~
      3~3~  P~3~  p~3~
      4~4~  M~4~  m~4~
      5~5~  S~5~  s~5~
      6~6~  L~6~  l~6~
      ~ 
    {GO}menu~
4.  {LABEL}1~
    {TEXT}key1~Enter the name of the caller  ~
    {Screen}{Screen}
    {ASSIGN}current~2~
    {GO}menu~
    {LABEL}2~
    {TEXT}key2~Enter the company of the caller  ~
    {Screen}{Screen}
    {ASSIGN}current~3~
    {GO}menu~
    {LABEL}3~
    {TEXT}key3~Enter the caller's phone number  ~
    {Screen}{Screen}
    {ASSIGN}current~4~
    {GO}menu~ {LABEL}4~
    {TEXT}key4~{Up}Enter the message
    {Enter}~
    {Screen}{Screen}
    {ASSIGN}current~5~
    {GO}menu~
    {LABEL}5~
    {TEXT}key5~{Up}Enter special instructions
    {Enter}~
    {Screen}{Screen}
    {ASSIGN}current~6~
    {GO}menu~
    {LABEL}6~
    {CHAR}key~{^\}Store in PHONELOG.TXT (
    {^]}Y{^\}es/{^]}N{^\}o)?  {^]}Y{^\}
    {Left}~
    {IF}"{VARIABLE}key~"="y"|"{VARIABLE}key~"="Y"|
    "{VARIABLE}key~"="{Enter}"~
       {ASSIGN}log~PHONELOG.TXT~
       {GO}record~
    {ELSE}
       {TEXT}log~Enter the name of the phone log  ~
       {GO}record~
    {END IF}
5.  {LABEL}record~
    {DISPLAY OFF} {Footnote}FC
    {Backspace}y
    Date:  {Date/Outline}T{Enter}{Enter}
    Time:  {Date/Outline}F8:90{Enter}T{Enter}{Enter}
    The Caller:   {VARIABLE}key1~{Enter}{Enter}
    The Company:  {VARIABLE}key2~{Enter}{Enter}
    The Phone #:  {VARIABLE}key3~
    The Message:  {Indent}{VARIABLE}key4~{Enter}{Enter}
    Instructions:  {Indent}{VARIABLE}key5~{Enter}
    **************{Enter}{Enter}
    {Home}{Home}{Up}
    {Block}{Home}{Home}{Down}
6.  {ON ERROR}{GO}error~~
    {Block Append}
    {VARIABLE}log~{Enter}
    {ON ERROR}~
    {Exit}
    {Backspace}y
    {Screen}{Screen}
    {Setup}ID{Exit}{Exit}
7.  {CALL}clear~
    {QUIT}
8.  {LABEL}error~
    {PROMPT}Error!!  ~
    {BELL}
    {WAIT}15~ {Screen}{Screen}
    {CALL}clear~
    {QUIT}
9.  {LABEL}cancel~
    {Screen}{Screen}
    {CALL}clear~
    {QUIT}
10. {LABEL}clear~
    {ASSIGN}key1~~
    {ASSIGN}key2~~
    {ASSIGN}key3~~
    {ASSIGN}key4~~
    {ASSIGN}key5~~
    {ASSIGN}log~~
    {ASSIGN}current~~
    {ASSIGN}key~~
    {RETURN}

 

QUICK CALCULATOR

Unlike some word processors, WordPerfect lacks a separate keyboard entry calculator. In order to perform ordinary math calculations with WordPerfect -- addition, subtraction, multiplication, and division -- you must set up a math definition, turn math on, then enter the numbers in the proper columns. A handheld pocket calculator is easier, even if you have to root through your desk to find it.

But the QUIKCALC.WPM macro takes some of the hassle out of direct keyboard calculations. It first sets up a table in a footnote window, then then asks you to enter the numbers and calculation operator. The results are shown on the screen. A little crude but it works.


QUIKCALC.WPM (provided on the Applications Disk)

1.  {ON ERROR}~
    {ON CANCEL}{GO}cancel~~
2.  {DISPLAY OFF}
    {LABEL}start~
    {Footnote}FC{Backspace}y
    {Columns/Tables}TC
    4{Enter}1{Enter}{Exit}
    {DISPLAY ON}
3.  {TEXT}#1~Enter first number  ~
    {VARIABLE}#1~
    {Item Right}
    {CHAR}op~Enter math operator (+ - * /)  ~ {VARIABLE}op~
    {Item Right}
    {TEXT}#2~Enter second number  ~
    {VARIABLE}#2~
    {Item Right}
4.  {DISPLAY OFF}
    {Columns/Tables}MF
    A1{VARIABLE}op~C1{Enter}
    MC
    {Exit}
    {DISPLAY ON}
5.  {LABEL}do_again~
    {CHAR}key~{^\}Do another ({^]}Y{^\}es/{^]}N{^\}o)?  
    {^]}Y{^\}{Left}~
    {CASE}{VARIABLE}key~~
      {Enter}~again~
      Y~again~ y~again~
      N~quit~  n~quit~
      ~
    {GO}do_again~
6.  {LABEL}again~
    {DISPLAY OFF}
    {Exit}{Backspace}y
    {GO}start~
7.  {LABEL}quit~
    {DISPLAY OFF} {Exit}{Backspace}y
    v{QUIT}
8.  {LABEL}cancel~
    {DISPLAY OFF}
    {Exit}
    {IF}{SYSTEM}menu~!=65535~
        {Exit}
    {END IF}
    {Backspace}y

 

QUIZ GAME

The quiz macro is an engine that you can use with any question/answer sheet you want to devise. An example of a question/answer sheetis providfed on the Applications Disk. To work properly, your question/answer sheet must be formatted the same way.

The document should use single spacing between all lines, and the answer for the previous question must start with the @ character. The @ character cannot be used in any other part of the text (you can change the character if you wish but you must modify the QUIZ.WPM macro to do so). The end of the answer is identified by the ^ caret symbol. The ^ symbol cannot be used in any other part of the text. All questions must be numbered consecutively, starting at 1.

The question/answer document, called QUIZ.TXT, can be any length and you can ask as many questions as you want. The macro is set up for multiple choice answers with five possible selections, but you can modify the macro to accept any type of question and answer format.


QUIZ.WPM (provided on the Applications Disk)

1.  {ON NOT FOUND}{GO}quit~~
    {ASSIGN}question~1~
    {ASSIGN}right~0~
    {ASSIGN}wrong~0~
    {DISPLAY OFF}
    {Switch}
    {IF}{SYSTEM}document~!=256~
        {GO}doc_full~
    {END IF}
    {Switch}
    {IF}{SYSTEM}document~!=256~
        {GO}doc_full~
    {END IF}
    {Retrieve}quiz.txt{Enter}
2.  {LABEL}start~
    {Search}{VARIABLE}question~{Search}
    {Block}{Search}@{Search}
    {Left}{Left}{Block Copy}
    {Switch}
    {Enter}{Home}{Down}{End}{Enter}{Enter}
3.  {DISPLAY OFF}
    {Switch}
    {Search}@{Search}{Right} {Block}{Right}
    {Macro Commands}Aanswer{Enter}
    {Left}{Block}{Search}^{Search}
    {Left}{Block Copy}{Cancel}
    {Switch}
4.  {DISPLAY ON}
    {LABEL}question~
    {CHAR}key~Enter your choice.  ~
    {IF}"{VARIABLE}key~"="{VARIABLE}answer~"~
        {GO}correct~
    {ELSE}
        {GO}incorrect~
    {END IF}
5.  {LABEL}correct~
    {DISPLAY ON}
    That is correct.{Enter}
    {Move}RB
    {CHAR}key~Press any key to go on  ~
    {ASSIGN}right~{VARIABLE}right~+1~
    {GO}count~
6.  {LABEL}incorrect~
    {DISPLAY ON}
    {BELL}
    That is incorrect.{Enter}
    {Move}RB
    {CHAR}key~Press any key to go on.  ~
    {ASSIGN}wrong~{VARIABLE}wrong~+1~ {GO}count~
7.  {LABEL}count~
    {DISPLAY OFF}
    {Exit}nn
    {ASSIGN}question~{VARIABLE}question~+1~
    {Switch}
    {GO}start~
8.  {LABEL}quit~
    {DISPLAY ON}
    {ASSIGN}#questions~{VARIABLE}question~-1~
    {Exit}nn{Switch}{Exit}nn
    {IF}{VARIABLE}right~>{VARIABLE}wrong~~
        Congratulations!  
    {END IF}
    Out of {VARIABLE}#questions~ questions, you got:
    {Enter}
    {END IF}
    Out of {VARIABLE}#questions~ questions, you got:
    {Enter}
    {Tab}{VARIABLE}right~ questions answered correctly.
    {Enter}
    {Tab}{VARIABLE}wrong~ questions answered incorrectly.
    {CHAR}key~Press a key to clear the screen  ~
    {Exit}nn
    {Switch}
    {QUIT} 
9.  {LABEL}doc_full~
    {BELL}
    {CHAR}key~The document screens aren't empty.
    Press a key ~
    {QUIT}

If you plan on creating many quiz games, make copies of the quiz macro. Give the copies easily identifiable names. Change the file name after the {Retrieve} instruction to match the question/answer document you are using.

 

MACRO GREETINGS

Tired of starting WordPerfect and staring at a blank document? This proverb maker macro displays a timely saying at the bottom of the screen every time you start WordPerfect. The sayings are stored is a proverb file (appropriately named HELLO.TXT). You can have any number of sayings in the file and they will repeat when the macro has gone through the entire list.

The macro uses the /M-macro startup option to run automatically when WordPerfect first loads. Rather than typing:

WP /m-hello

each time you want to start WordPerfect, include the startup option in a batch file. You can name the batch file anything you like as long as it doesn't conflict with another batch file or the name of a program. For example, you can name the batch file WPBAT.BAT, but not WP.BAT (WP.EXE is the name of WordPerfect).

To make the batch file, be sure you are in the same directory as WP.EXE, and enter the following in DOS:

COPY CON: WPBAT.BAT
WP /M-HELLO
[F6]
[Enter]

HELLO.WPM and HELLO.TXT must be on the default drive and directory or WordPerfect won't be able to find them (if you use a default macro directory, the HELLO.WPM macro should be placed there). You can, of course, place them in another drive or directory, but you must modify the batch file and macro accordingly.

The format of HELLO.TXT , which contains the actual greeting text, is simple:

Initially, place a @ symbol immediately before the text of the first line. This symbol is used by the macro as a place marker for identifying the next proverb to use. The @ symbol moves down one line each time the macro is activated.


HELLO.WPM

1.  {DISPLAY OFF}
    {Exit}nn
    {Retrieve}hello.txt{Enter}
2.  {Search}@{Search}
    {Backspace}
    {ON NOT FOUND}{GO}special~~
3.  {LABEL}start~
    {Block}
    {Search}{Enter}{Search}
    {Macro Commands}Atext{Enter}
    @
    {Save}
    {IF}{SYSTEM}menu~=32809~
        hello.txt{Enter}y
    {END IF}
    {IF}{SYSTEM}menu~=65027~ {Enter}{Enter}
        hello.txt{Enter}y
    {END IF}
    {Exit}nn
    {DISPLAY ON}
4.  {CHAR}key~{VARIABLE}text~~
    {Screen}{Screen}
    {QUIT}
5.  {LABEL}special~
    {Block}
    {Home}{Home}{Home}{Up}
    {GO}start~

Of course, you are not limited to greek mythology. You can use classic maxims such as Murphy's Laws, old almanac sayings, fortunes ("You will meet a tall, dark macro"), even proclamations of company policy.

 

PROJECT TIMECARD

If you need to keep track of time you spend on projects for clients, you'll find the TIMECARD.WPM a handy addition to your WordPerfect toolbox. The macro functions similarly to PHONE.WPM, described earlier in this chapter. Because the TIMECARD.WPM macro is very similar to PHONE.WPM (albeit without as many bells and whistles) a step-by-step description won't be provided for it here.

To use TIMECARD.WPM (which is provided on the Applications Disk):

  1. Start the macro.
  2. At the menu that appears, make your selection by entering a number from 1 to 5. For example, to enter the client's name, press 1, then write the name. Press [Enter] when you are done.
  3. Repeat step 2 until all the information is entered.
  4. When entering start and stop times, pressing [Enter] without typing a date automatically inserts the current time.
  5. When all information has been entered, press 5 for log.
  6. Indicate if you want to save the log under the standard TIMECARD.TXT file or in a file of your choice. (If you want to use the TIMECARD.TXT file, press Y, y, or [Enter].)

 

ATTRIBUTE CHANGER

You get an anxious call from your editor who tells you that all the underlining in your manuscript must be converted to bold. While you could go through the manuscript and exchange each underline code for bold, or prepare a special purpose macro just for the conversion, and easier method is using the CHANGE.WPM macro, detailed here. This macro lets you trade any attribute for any other. You can change attributes globally, or request that the macro stop at each one and ask if you want to change it.

CHANGE.WPM is a rather lengthy macro, and many of its routines have been detailed in previous chapters. We'll concentrate on just the special sections of the macro.


CHANGE.WPM (provided on the Applications Disk)

(partial listing)

{CHAR}key~{Del to EOP}
Select the attribute you wish to CHANGE FROM:{Enter}
1 Underline         2 Strikeout       3 Bold{Enter}
4 Double Underline  5 Redline         6 Italics{Enter}
7 Small Caps        8 Outline         9 Shadow{Enter}
A Printer Function  B Fine            C Small{Enter}
D Large             E Very Large      F Extra Large
{Enter}
G Superscript            H Subscript{Enter}{Enter}
Press a number or letter key  ~

CHANGE.WPM lets you select from a wide variety of attributes. The CHANGE FROM and change TO menus are identical, except that CHANGE TO lacks a printer function choice.

{LABEL}case~
{CASE}{VARIABLE}key~~
1~ul~ 2~so~ 3~bo~ 4~du~ 5~rd~ 6~it~ 7~sc~ 8~ol~ 9~sh~
A~pf~ a~pf~ B~fn~ b~fn~ C~sm~ c~sm~ D~lg~ d~lg~
E~vl~ e~vl~ F~el~ f~el~ G~sp~ g~sp~ H~sb~ h~sb~
~
{CHAR}key~Not a valid choice.  Press a key to continue  ~ 

The macro uses the same {CASE} structure for both the CHANGE TO and CHANGE FROM menus. Menu items are references by number and letter, but not both (CHANGE.WPM does not use mnemonics for the CHANGE FROM and CHANGE TO menus).

{LABEL}ul~
{ASSIGN}{VARIABLE}attrib~~{Underline}~
{RETURN}
{LABEL}so~
{ASSIGN}{VARIABLE}attrib~~{Font}as~
{RETURN}

Each attribute is assigned a unique label, where the attrib variable is assigned the font attribute. This variable serves to both search for the desired attribute, and to replace it.

{LABEL}search~
{Search}{VARIABLE}from~{Search}
{Block}{Search}{VARIABLE}from~{VARIABLE}from~
{Left}{Backspace}{Search}

CHANGE.WPM uses the search feature to find font attrinbutes. When found, the macro turns block on and blocks all of the text between the attribute on and off codes.

{LABEL}change~
{DISPLAY OFF}
{VARIABLE}to~{Left}{Backspace}

The "change" routine is used to exchange the attribute. The original attribute codes are deleted (deleting one deletes the other), and the blocked text is formatted with the new attribute (as assigned with the to variable).

 

ASCII CODE DISPLAY

WordPerfect can generate some 1,500 different characters. To make it easier to access these characters, the program offers the compose key and numbered character sets. The standard array of 254 printing ASCII characters are among WordPerfect's character sets. The standard ASCII characters are divided among many sets, making it difficult to remember which code combination produces what key. You may also be somewhat familiar with the ASCII "alphabet," accessing the built-in line graphics characters, special symbols, and so forth.

CHARS.WPM displays all 254 printable ASCII characters in a convenient screen three-part screen display. The characters are

displayed as a message prompt, so you can use this macro while working with other documents (the macro should only be used at a document screen, as it requires that the screen be refreshed to clear the display). The macro shows the printable character and its corresponding ASCII number.

To use CHARS, press N to go to the next screen, and P to back up. To quit, press Q.

CHARS.WPM is provided on the Applications Disk.

 

DOCUMENT LOGGER

DOS automatically updates the time and date attributes of files whenever you create and edit documents. If you need to keep track of ALL the times and dates you edit a document, use LOGGER.WPM The macro stores a running log of edits in a special style, called Logger. You can view the log in the Styles editing screen and, if you'd like, apply the style to the beginning or end of the document, thereby printing the log in the file.


LOGGER.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Style}
{ON NOT FOUND}{GO}no_style~~
nlogger{Enter}
E {GO}log~

{LABEL}no_style~
{Enter}
C
N  Logger{Enter}
T  O
D  Document logger{Enter}
{GO}log~

{LABEL}log~
C  {Home}{Home}{Home}{Down}
{Date/Outline}T{Tab}{Tab}
{Date/Outline}F8:90{Enter}T{Enter}
{Exit}{Exit}{Exit}
{Setup}ID{Exit}{Exit}
{CHAR}key~Document logged.  Press a key  ~

LOGGER.WPM automatically creates the Logger style the first time you use the macro. Thereafter, it edits the style already in the document.

 

ELAPSED DOCUMENT TIMER

If you need to keep track of elapsed time you've spent on a document, the TIMER system described here (and available on the Applications Disk) may provide some help. TIMER is composed of three parts:

To use TIMER, be sure that both the keyboard and macro are in your current macros directory, and the style is in the current styles directory (if you haven't specified special directories for macros and styles using the Location of Files option under the Setup key, these files should be placed in the main WordPerfect directory).

  1. Choose the Setup key ([Shift]-[F1]), and press K for keyboard layout. Highlight the TIMER layout, and press S for Select. Press the Exit key to return to the editing screen.
  2. Start TIMER by pressing [Alt]-[F10], and typing TIMER. Press [Enter].
  3. Press any key to start the timer running. The *please wait* message will go out when the macro is done. You may not write and edit, as usual. Note that TIMER is no longer active, so you can create, edit, and use macros without any worry of interaction. 3. When you're ready to save the document, press [F10]. The TIMER macro is run again, this time, recording the elapsed time between the moment you first started TIMER, and now. DO NOT execute the TIMER macro again (if you do, press the Cancel key repeatedly to get back to the main editing screen).
  4. Provide a name for the document, or -- if you've saved the document previously -- accept the old name by pressing [Enter]. The file is now saved.

You can continue working (and saving) your document. TIMER will track the time spent in the current session (meaning the time since the last save), and all cumulative time since you first created the document. If you'd like to save the document normally, press [Ctrl]-\.

To see the elapsed time, choose Styles ([Alt]-[F8]), and select the "timer" style. Press E (for Edit) and C (for codes). The style definition records the current and cumulative editing times of the document, in hours and minutes. You can include the elapsed time information by applying the style to the document.

Note that TIMER won't work if the editing session extends over midnight. The macro has a built-in warning mechanism that prevents it from logging a session that's spanned from one day to the next.

 

TIME TRACKER

If you don't need to track the elapsed time spent writing and editing a document, but would like to keep tabs on the time spent on the phone or in meetings, you can use TIMETRAK.WPM, provided on the Applications Disk.

To use TIMETRAK.WPM:

  1. Invoke the macro, as usual.
  2. At the prompt, press any key to start the timer. The Cancel key stops TIMETRAK.
  3. TIMETRAK is now running (avoid using other macros). When you're done with your phone call or meeting, press [Ctrl]-S. This tells TIMETRAK that you want to stop. (Note: if Ctrl-S is remapped in a keyboard layout, TIMETRAK could behave erratically. Either change the keyboard definition, or edit the macro to use a key other than Ctrl-S).
  4. At the prompts provide: the name of the caller, the caller's business affiliation (if any), account number, and the reason for the call. The macro then saves the file, using the last name of the caller as the file name. A .TIM extension is added to the name (if the caller's last name is over eight characters, only the first eight characters are used in the file name).

The TIMETRAK.WPM macro appends the logging information to the file, so one client file can contain many logs. Each log entry includes the date, time, and duration of the call or meeting.

 

MISCELLANEOUS DOCUMENT MACROS

In the course of writing this book, I developed numerous miscellaneous macros designed to make writing and editing easier. These don't strictly fit into the categories defined by the other chapters so is the best place for them as any.


Level 1 Paragraph Numbering

Here is a macro that automatically numbers the next paragraph you type for you. It's useful when writing numbered lists, some screenplays, and instruction manuals. As long as you don't define a new paragraph numbering style, WordPerfect will number consecutively those paragraphs that have a [Par Num] code in front of them. This macro treats all paragraphs as level 1.


PARNUM.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Left Mar Rel}
{Date/Outline}P1{Enter}
{Tab} {DISPLAY ON}


The {Left Mar Rel} code is created by pressing [Shift]-[Tab].


Manual Level Paragraph Numbering

Instead of numbering each paragraph at level 1, this macro lets you assign whatever level you want.


AUTOPAR.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Left Mar Rel}
{Date/Outline}P{Enter}
{CHAR}1~Enter the level number  ~
{VAR 1}{Enter}
{Tab}
{DISPLAY ON}


Counting Words

This macro counts the number of words in the document.


WDCOUNT.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Spell}
C
{DISPLAY ON}


Number of Occurrences

If you're interested in the number of occurrences of a particular word, you can use COUNT.WPM to make the task simple and painless.


COUNT.WPM (provided on the Applications Disk)

{ON NOT FOUND}{GO}display count~~
{ASSIGN}1~0~
{TEXT}0~Enter the word to find.  ~
{LABEL}loop~
{DISPLAY OFF}
{Search}{VAR 0}{Search}
{ASSIGN}1~{VAR 1}+1~
{GO}loop~

{LABEL}display count~
{DISPLAY ON}
{CHAR}9~The word "{VAR 0}" appeared {VAR 1} time(s) in the
document.{Enter}Press any key to continue.~ {DISPLAY OFF}
{DISPLAY ON}


Quick Save

SAME.WPM is a quick save macro for saving the current document to disk. For ease of use, rename it ALTS.WPM so you can invoke it simply by pressing [Alt]-S. You must have already saved the document and named it before you can use this macro.


SAVE.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{Save}{Enter}y
{DISPLAY ON}


List Macros

Even if you regularly store macros on a separate disk or subdirectory, some will inevitably wind up in your default WordPerfect disk/directory. You can easily display only macro files using MACLIST.WPM (rename it to an Alt-letter key so you can call it up more easily).


MACLIST.WPM (provided on the Applications Disk)

{List}macros\*.wpm
{Enter}


Clear Screen

CLS.WPM clears the contents of the current document window. Because this can cause irretrievable loss, the macro includes its own fail-safe warning. This macro recognizes lower case y only. If you want it to recognize both upper and lower case Y, add another {IF} instruction to test for "Y."


CLS.WPM (provided on the Applications Disk)

{DISPLAY OFF}
{BELL}{BELL}
{CHAR}0~{^R}Sure you want to clear the current 
document? (y/n)~ 
{IF}"{VAR 0}"="y"~
     {ELSE}{QUIT}
{END IF}
{Exit}nn


Macro Starter

This macro is a "macro starter," for use if your macros are on another disk or in another directory. To access a macro, use the macro starter, then type the name of the macro you want to use. You don't need to enter drive names or directories. This starter macro assumes your macro files are stored in a subdirectory called "macros." As provided on the Applications Disk, the macro is called MACSTART.WPM. For ease of use, you'll probably want to rename it something like ALTM.WPM so you can access it by pressing [Alt]-M.


MACSTART.WPM (provided on the Applications Disk)

{TEXT}key~Type the name of the macro and press Enter  ~
{Macro}macros\{VARIABLE}key~{Enter}


Displaying the Ruler

WordPerfect's ruler is normally hidden so that the screen displays a full 24 lines of text. If you'd prefer, you can display the ruler -- showing the margins and tab settings -- on the 25th row of the display. WordPerfect then uses line 24 for status display, leaving you rows 1 through 23 for text. RULER.WPM lets you easily turn the ruler on or off, as you wish.


RULER.WPM

{CHAR}key~{^]}Ruler:  {^]}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~
{Screen}W23{Enter}
{QUIT}
{LABEL}off~
{Screen}W24{Enter}
{QUIT}


Split Screen

The RULER.WPM works by setting the window to 23 lines. By entering a lower number, you not only display the ruler, but a portion of Doc 2, as well. By entering a number such as 12 or 13 for the window split, you effectively cut the display in half, with one half showing Doc 1, and the other Doc 2. SPLIT.WPM lets you split and unsplit the display as you desire.


SPLIT.WPM (provided on the Applications Disk)

{CHAR}key~{^\}Window Split:  {^]}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~
{Screen}W12{Enter}
{QUIT}
{LABEL}off~
{Screen}W24{Enter}
{QUIT}


Line Draw

LINEHOR.WPM and LINEVER.WPM are useful when creating forms using WordPerfect's Line Draw feature. LINEHOR.WPM lets you define the number of lines you want, their spacing, and their length. LINEVER.WPM draws vertical lines of a specific length. Because you probably want to add vertical lines only at specific points in your form, LINEVER.WPM doesn't prompt you for spacing or number of lines.


LINEHOR.WPM (provided on the Applications Disk)

{ASSIGN}2~0~
{TEXT}1~How many lines?  ~
{TEXT}3~Length of each line? ~
{TEXT}4~Spacing between each line? ~
{LABEL}loop~
{DISPLAY OFF}
{Screen}L CO{Enter}
{Esc}{VAR 3}{Right}M
{Esc}{VAR 4}{Down}0
{Esc}{VAR 3}{Left}
{ASSIGN}2~{VAR 2}+1~
{IF}{VAR 1}={VAR 2}~
{ELSE}{GO}loop~
{END IF}


LINEVER.WPM (provided on the Applications Disk)

{ASSIGN}3~0~
{TEXT}1~Length of the line?  ~
{DISPLAY OFF}{Screen}L
CO{Enter}
{Esc}{VAR 1}{Down}M
{Right}0
{Esc}{VAR 1}{Up}

The specifications for the horizontal lines are:

The specifications for the three vertical lines are:

 

Line Across

Often, all you want is a simple line that stretches across the page from margin to margin. LNACROSS.WPM does it for you. The macro places lines from margin to margin, regardless of the current document settings. Before you start the macro, the cursor should be at the left margin.


LNACROSS.WPM (provided on the Applications Disk)

{DISPLAY OFF}{Screen}L
CO{Enter}
{Home}{Right}
{Exit}{Home}{Left}


Bow Draw

This macro draws a box with the dimensions you specify. The macro uses WordPerfect's Line Draw feature, so you must have a printer capable of printing the Extended IBM PC character set.


BOX.WPM (provided on the Applications Disk)

{TEXT}1~Width of box? ~
{TEXT}2~Length of box? ~
{DISPLAY OFF}
{Screen}L
1{Esc}{VAR 1}{Right}
{Esc}{VAR 2}{Down}
{Esc}{VAR 1}{Left}
{Esc}{VAR 2}{Up}
0
{DISPLAY ON}

Although the dimensions are not the same, the box is almost perfectly square. The reason? WordPerfect's uses character spaces for the width dimension and line spacing for the length dimensions. If you need to create a box of a particular dimension, either use WordPerfect's graphic line draw feature of calculate the size using this formula (assuming 10 cpi printing settings):

 

Printer Compatibility

The Line Draw feature of WordPerfect uses the extended (above ASCII 128) character set of the IBM PC ROM. Not all printers are compatible with this character set, so if you format a document with Line Draw graphics, they may not appear on paper. The manual that came with your printer should tell you if it is IBM PC extended character set compatible. Also, be to choose the correct printer driver when installing WordPerfect.

As long as your printer is capable of graphics (almost all formed character printers are these days), and WordPerfect supports the printer with an appropriate driver, you can produce documents with all sorts of lines and boxes. But you must do so with WordPerfect's graphic line drawing feature. See Chapter 12, "Desktop Publishing," for more information on using the graphics capabilities of WordPerfect.


Record Sorter

I needed a way to maintain my database of movies and rather than using a database program, or even an electronic spreadsheet with database capabilities, WordPerfect's merge feature seemed a good choice. But the problem with WordPerfect is that it requires you to go through numerous steps to do otherwise simple chores, such as resorting lists and updating records. A couple of macros changed all that.


SORTDIR.WPM (provided on the Applications Disk)

{Merge/Sort}S
{Enter}{Enter}
TPKa2{Enter}
1{Enter}
2{Enter} {Exit}P


Secondary Merge File List Manager

List maintenance using secondary merge files is fairly straightforward for most tasks. New records are added at the end and the file is resorted as desired. Records can also be compared and acted upon using WordPerfect's advanced sorting operators. But what it you just want to delete a record? Normally, you'd have to manually take out every line (along with any errant codes), but this macro makes the job easy. As written, the macro looks for the pairing of {End Record} and [HPg] codes. Your secondary merge files should have the same format, or else you need to rewrite the macro.


RECDEL.WPM (provided on the Applications Disk)

{CANCEL OFF}
{INPUT}Move cursor to record; Enter when done.  ~
{Block}{Search}{Merge Codes}E{HPg}{Search}
{Del}y

To use the macro, start it, then scroll through the document and stop on the first field of the record you want to delete. Press the [Enter]key. If you decide you don't want to delete a record, move to the very end of the document, then press [Enter].


Backwards Printer

Don't laugh -- a macro that prints a file in backwards order is more useful than you think, particularly if you own one of the older models of the Hewlett-Packard LaserJet or Apple LaserWriter. Both of these printers don't collate the pages in their proper order; the last page is on the top and the first page is on the bottom. If the print job is any length at all, it means you have to go through the stack of papers and reshuffle them into their proper order.

Two versions of backward printing macros are provided here. BKPRINT1.WPM is WordPerfect 5.0 compatible, and requires that you enter the total number of pages in the document. The macro then starts at the end of the document and prints it page by page, in reverse order. The BKPRINT2.WPM macro uses the {SYSTEM} Page variable to test for the total number of pages. This number is then used in a backwards {FOR} loop -- the loop starts counting from the last page, to page 1.

Note that both of these macros are best used with documents under about 20 pages.


BKPRINT.WPM (provided on the Applications Disk)

{ASSIGN}0~0~
{TEXT}2~Please enter the number of pages in the 
document.  ~ {Home}{Home}{Down}
{ASSIGN}1~{VAR 2}-1~
{LABEL}count~
{IF}{VAR 0}={VAR 1}~{Print}2{QUIT}
{ELSE}{ASSIGN}0~{VAR 0}+1~{GO}print~
{END IF}

{LABEL}print~
{Print}2
{Page Up}
{GO}count~


BKPRINT2.WPM

{DISPLAY OFF}
{PROMPT}Please wait  ~
{Home}{Home}{Home}{Down}
{ASSIGN}pages~{SYSTEM}page~~

{FOR}print~{VARIABLE}pages~~1~-1~
{Print}P
{Page Up}
{END FOR}

 

ADVENTURE!

WordPerfect certainly isn't made as a tool for building adventure games. But with macros, its possible to construct interactive fiction macros that let you explore exotic, far-away places, hunt for treasures and piece together a mysterious riddle. To demonstrate some of WordPerfect's macro features, I have developed a small, "skeleton" adventure game that consists of six rooms, sundry items to examine, pick up, and put down, and illustrative text to accompany the game play.

The game system outlined here is just one approach of many to tackle the unique problem of interactive fiction and text adventures. There are many limitations and draw-backs of the system as presented; I leave it up to you to improve on the basic framework and expand the game any way you see fit.

The reason for developing and studying the game is many fold: First and foremost, it teaches you many unique aspects of advanced WordPerfect macros. Many of the techniques used in the adventure game can be applied to other, more serious word processing applications. Second, it helps you better understand how WordPerfect works, so you can master the features and operation of the program, whether or not you are creating or using macros. And third, it's fun.


Conventional Text Adventure Game Design

Among the first text adventure games specifically designed for personal computers were those written in BASIC by Robert LaFore and sold through mail order by Scott Adams Adventure International. These prototype adventures were crude and offered limited interaction, but they served as excellent models for expanding the idea of fiction gaming on small computers.

A reasonably large and complex all-text adventure game called Dungeon had been developed in the late 1970s for use on mainframe and mini computers. That game, in one version or another, became available for personal computers and sparked the growth of the interactive fiction medium.

Although some adventure games deviate from the norm, most of them are modeled after Dungeon. The basic text adventure consists of several "rooms," which you, as the player, visit by entering compass directions (including up and down). In many of the rooms are objects that are meant as "keys" for solving riddles or accomplishing some task later on. Some objects are painfully obvious -- you don't need to dig deep to find them.

To make the game more difficult (and thus more enjoyable), some of the object are red herrings, and either serve no purpose at all or actually prevent you completing the game. Dungeon, like most adventure games, allow you to collect only a certain number of objects at any one time. These object are carried by you in an invisible backpack. Most games call the backpack the "inventory." In fact, you can usually review the contents of the backpack by typing inventory. Most objects carry a certain value (either positive or negative). This value contributes to your score.

Dungeon was designed so that you scored whenever you picked up an object. The goal was to search all the rooms, unlock the various hidden treasures, and carry them out to a safe holding area. The more objects, the higher the score. The game also kept track of your turns. The more turns at the end of the game (if you ever got there at all), the lower your overall score. Some of the more advanced adventure games out these days score on other criteria, such as rooms visited, puzzles unlocked, demons or monsters defeated, and so forth.

Although the conventional adventure game scenario is old and a bit tired, it serves as a good example of how to build your own. The object of your game is to have players search through rooms and discover its objects. Some objects may be worthless, others may be extremely valuable.

The example adventure game presented in this chapter lacks a scoring mechanism, and none of its objects are used for anything. Rather, the game serves as a shell for your own further experimentation. Feel free to adapt the basic game by adding whatever features you feel will add tension and excitement.

While you could use WordPerfect's named variables to store information about the inventory and other items, you can also keep this data tucked away in a scratch pad document. The example adventure game, called "City of a Thousand Terrors" (so named for no particular reason), uses a document called ADVENT.TXT. The sole purpose of this document is to record the placements of the objects in the various rooms. You can easily add additional sections to the document and incorporate scoring mechanisms, tags or keys that test if the player has accomplished some goal.

All adventure games have a "parser" for communicating between the player and the computer. The parser breaks down phrases and even entire sentences and draws out those words that have meaning to the game. For example, entering "GO EAST" is broken by the parser into its component "GO" and "EAST" components. The parser is semi-intelligent, and the better the parser, the better the communications between game and player.

WordPerfect's macro feature does not lend itself well to building a sophisticated parser, although it can be done with version 5.1. I have elected to leave a parser out, because it tends to slow the game down, and instead have used a menu system where the available choices are shown on screen (details on constructing macro parsers can be found in Chapter 19, "For Pros Only: Advanced Topics."

In the example adventure game presented here, the main menu presents the prompt:

1 Look; 2 Get; 3 Drop; 4 Inventory
5 Examine; 6 Go; 7 Help

The help option is inactive.

Pressing 6 (for Go) displays another menu, this one displaying:

1 East; 2 West; 3 North; 4 South

You can add similar menus to other portions of your adventure game. For instance, you might include a rather large full-screen menu that offers suggestions for what to do with certain groups of objects.


Game Pieces

The WordPerfect macro adventure game consists of 11 macros.

The game requires the file ADVENT.TXT in order to keep track of the objects in each room. Its format is fairly simple but exact. Rooms are contained in their own footnotes. This allows you to perform selective searches within each footnote window. This document is modified during game play, but never saved by WordPerfect, so you may safely lock it against accidental erasure and over-writing.

All adventure games have maps that indicate the direction of travel from one location or room to another. Each room is numbered for easy reference both by you and the game system. Note that you can only in certain directions in each room. The ROOM# macros, described below, control the passage of movement from one room to another.


Use of Variables

The WordPerfect adventure game system, as presented here, actively uses five of the program's numbered variables.

You can use the remaining numbered variables, or just about any number of named variables (up to the memory capacity of your computer) to keep score, to keep track of special objects, and more.

 

BLACKJACK CARD GAME

If you thought an adventure game was an unusual application for a WordPerfect macro, you haven't played WordPerfect Macro Blackjack. This is a complete, fully-functional blackjack (or 21) card game, written entirely in the WordPerfect macro language. You are the player and WordPerfect is the dealer. There can be only one player at a time.

The macro features a 52-card deck, automatic shuffling, pup-up card graphics, scoring, and more. For simplicity, it does not include some advanced blackjack options, including splits, double-down, or insurance. BLACKJAK.WPM is provided on the Applications Disk, but is not detailed here because of its size.

To start the game, press [Alt]-[F10], type BLACKJAK, and press the [Enter] key. If necessary, provide the disk and full path if the BLACKJAK.WPM file does not reside in the default disk/directory or in the default macros directory (as set by the Location of Files option under the Setup key).

At the prompt, enter the amount you have in your "bank." Macro Blackjack allows you to deposit from $10 to $10,000 in the bank. WordPerfect will then shuffle the cards for you. Press any key to stop shuffling (the deck may be shuffled twice when the game first starts, so you'll have to stop the shuffle two times). Enter a bet for the next hand -- from $1 to $1,000 dollars. Note: When entering dollar amounts, provide whole numbers only, without commas or dollar signs. Entering non-numeric characters may disrupt the action of the game.

You can stop the game at any point by pressing the [F1] (Cancel) key.

IMPORTANT NOTE: Macro Blackjack uses extensive programming commands to shuffle the deck. The faster the computer, the faster the deck is shuffled. The game is best played on an AT-class or better computer, running at 8 MHz, or faster. If the game appears to have stopped after shuffling (you will see a "Thank you, please wait" message) be patient. The macro will re-activate shortly.

WordPerfect deals two cards to you, and two to itself (one of its cards is kept face-down; yours are dealt face-up). At the prompt, indicate whether you want to Hit, Stand, or Quit.

WordPerfect Macro Blackjack follows general Las Vegas blackjack rules: dealer must play to 16 and stand on 17. Aces are considered 1 or 11, depending on the overall score. While WordPerfect Macro Blackjack will not disrupt a document currently in the editing window, the game is designed to be run from a "clean" screen. Be sure to save any documents you happen to be working with, and clear the screen (press Exit, n, n) before starting the game.

The BLACKJAK.WPM macro file is approximately 20K in size, and should play on your computer regardless of the amount of free memory you have available. However, memory limitations under certain circumstances may prevent it from running properly. If the macro doesn't work right, clear both document windows and, if necessary, run WordPerfect without Shell. WordPerfect will not be able to load the BLACKJAK.WPM macro file into the internal macro editor unless you have at least 50K of available memory.

Feel free to study the BLACKJAK.WPM macro using the macro editor. For file size considerations, the macro is not commented, but it is organized in discrete functionality groups.

---

 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/