A WP8 logging macro
As you might have already guessed, it is also possible to have your WP8 template macro create a log for you as well. The same principle applies here as it did in the previous article: Once the information is stored in variables you can do anything with it. There are a few extra tricks we will need to know to do this effectively with WP8.
Record that macro
Let's start by recording a log macro. Because of the way WP8 works with documents, we have to be more careful than we were in WP51. Start WP8. (You should be looking at a blank document.) Create a new document, by pressing Ctrl-N. Now you should have two blank documents open, one in Document 1 and the other in Document 2. The log will stay in Document 1 and your report will be in Document 2. Switch to Doc 2, if you aren't there already, and start recording your log macro by pressing Ctrl-F10, typing a name for the macro, and pressing Enter. Now that the macro is recording switch to document 1, either by pressing the Document 1 button at the bottom of the WP8 window or by choosing it in the Window menu. When you get to Doc 1 press Enter and then switch back to Doc 2. Stop the macro from recording by pressing Ctrl-F10.
Edit the macro
To edit the log macro you need to go to the Tools Menu | Macro | Edit and then highlight the name of your log macro and click the Edit button. This will open your log macro into an editing screen. The macro should look like this:
The first line is unimportant, it just says that the macro was created with an English version of WordPerfect. The rest of the macro is fairly self-explanatory, we switched to Doc 1, pressed Enter, and switched back.
We have to get our variables to type their contents on the log between the first switch and the hard return. Position the cursor at the end of line that says "SwitchDoc (DocNum: 1)" and press Enter. Now start adding the Type command for the entries you want in your log followed by a Tab. You might add something like this:
These lines will type the job number, patient name, and doctor name separated by tabs into your log.
If you are using the WP8 count macros we created in the May issue you can also include the line count in your log. Just add another Type command after "Type (docname) Tab ()". Like this:
Of course, you will need to run the count macro before the log macro for this to work correctly.
The completed log macro might look like this:
Make sure you save and compile your macro after editing by pressing the Save & Compile button.
Creating the report and the log together
You can also save yourself a step and create your log at the same time you create the report. This method works best if you don't need a line count on your log.
The first thing to do is open your report macro for editing. Go all the way to the bottom of the macro and add the following lines:
Obviously, you can add or delete Type commands to suit your preferences for what you need the log to look like. Just remember the format is:
Where "variable" is the name of the variable you want WP to type.
The completed macro should look something like this:
When you are done editing press the Save & Compile button to save the macro.
Final thoughts
When we do a Switch command in WP51 the program automatically assumes that we need to open Doc 2 if it isn't already open. WP8 doesn't work that way. Because of the nature of WP8 we must open two documents before we even start working. If you neglect to do this you will generate an error, the Switch command will be ignored, and WP will type the log information straight into your report document.
It is also necessary to always keep your report in Doc 2 and your log in Doc 1. If you try to keep your report in Doc 1 and your log in Doc 2 when you close your report to start a new one your log (Doc 2) will automatically become Doc 1, messing everything up.
Lastly, since we are switching from Doc 2 to Doc 1 and back again, you should be in Document 2 before you run either the log macro or the modified report macro.
These techniques and commands will also work for users of the other Windows versions of Word Perfect (WP6.1, WP7, and WP9).
Copyright 1999 by Mike DeTuri (reprinted from Computer Solutions Vol. 1, Issue 4)