|
Make a key do "double duty"
by assigning a macro to it, and make the macro play only if the
key is struck multiple times (e.g., 2x, 4x, etc.) |
Here are macros that can
- create a special graphic line
with a few taps of the equals (=) key
- automatically enter a hard return
and simultaneous save the document
- delete multiple spaces at the
cursor location and replace them with a tab
- automatically expand QuickCorrect
abbreviations to create possessives
|
NOTE:
To copy the macro code below
into WordPerfect, select the text from beginning to end and copy
(Ctrl+C) it to the Windows clipboard.
Open a blank document in WordPerfect
and click on Tools, Macro, Macro Toolbar.
Position your cursor after
any codes in Reveal Codes, and click on Edit, Paste Special,
Unformatted Text to paste the macro code into the WP document
without any extraneous formatting or other unwanted codes.
Check the pasted text for long
lines that may have wrapped into two or more lines with a hard
return [HRt] or line break [Ln Brk] between them; remove the
hard return(s) or line break(s) to "glue" the lines
back together.
Save the pasted material with
the Save & Compile button on the Macro Toolbar. This will
save the macro to your default macros folder as shown in Tools,
Settings, Files, Merge/Macro. |
TIP
1
|
A user on a Corel newsgroup asked:
"In [Microsoft] Word, there's
a feature that lets you type, say, === and then hit enter, and
it automatically becomes a double line across the page. Doing
that with ### creates a triple line, with the line in the center
thicker that the ones on the outside. Is there a similar feature
in WordPerfect ...?"
My answer:
Yes, if you use four hyphens
("----") or equal signs ("====") at the beginning
of a line. There is a setting in WP and it must be toggled on:
Tools, Quick Correct, Format-as-you-go, Quicklines.
However .... If you want a different
graphic line than the single- and double-line defaults that
WP provides, this can be done with a macro assigned to the particular
key (say, the "=" key). For example, the following
macro will insert a full-width triple line (the center line being
thicker) if you assign it to the "=" key, and then
type four consecutive equal signs (on a blank line) in your document.
Please read the notes following the macro code.
- // Beginning of macro code -
Application(A1;"WordPerfect";Default)
- vCount:=0
//
If the character to the left is an equal sign (i.e., ASCII 61)
- IF(CTON(?LeftChar)=61) Type("=")
- While(CTON(?LeftChar)=61)
PosCharPrevious()
- vCount:=vCount+1
- Endwhile
- ForNext(x;1;vCount;1)
- PosCharNext()
- EndFor
- If(vCount=4)
- ForNext(x;1;vCount;1)
- DeleteCharPrevious()
- EndFor
- // Note:
The next 3 Graphics... lines were recorded (Insert, Shape, Custom
Line, etc.);
- // delete
them and re-record them to use a different line style -
- GraphicsLineCreate
()
- GraphicsLineStyle
(Style: "Triple 1")
- GraphicsLineEnd
(State: Save!)
- HardReturn()
Endif ELSE Type("=") ENDIF
- Quit
// End of
macro code
Operation:
|
When the macro is assigned to the
normal "=" key, pressing that key the first time makes
the "Else" condition true, and the macro inserts a
normal equal sign. Pressing that key again makes the "If"
condition true, and (if there are four equal signs to the left)
the macro counts and deletes all equal signs up to the cursor,
and inserts a graphical line in their place. |
Assign this macro
to the "=" key:
|
Click on Tools, Settings, Customize,
Keyboards tab. Select the keyboard you want to modify. (Or click
Copy to make a copy of it first: In the Copy Keyboard window,
select the keyboard to copy, click Copy, and "Rename the
object" with a new name, then click OK. Left-click the new
keyboard's name and click Select to use it.) Next, in the Customize
Settings window, click Edit to edit the keyboard definition.
Check the box at the bottom, "Allow assignment of character
keys". In the left window, scroll down to the "="
key and select it, then click Remove Assignment if there is any
current assignment (say, some other macro or feature). In the
right-hand window, click the Macros tab and then Assign Macro
to Key. Select the macro from the file directory, and click OK,
then Close until you are back in your document. |
Modification:
|
You can have the "#" key
(or any other unassigned key) perform this function by changing
"61" to "35" in the two relevant lines above.
Then assign the macro to the "#" key. (Note: I used
an old ASCII chart to get these numbers. There are lots of places
to get this chart; for example - http://www.ascii.cl/
and http://www.asciitable.com/) |
|
TIP
2
|
You could assign a macro to a
key that does something other than insert a graphical line. For
example, you could use the backslash key ("\") -- just
above the <Enter> key -- to enter a hard return and save
the file at the same time. Here's a macro to do it (also included
in MultiSav.zip). After
adding it to your macros folder, assign it to the bakslash key
in the same way as explained in the paragraphs above.
// - - - Macro code begins here
- - - // Assign this macro to the "\"
key. Then pressing backslash twice cause the macro to delete
the backslashes, then enter a hard return and save the file.
// To make the macro work with 3 consecutive
backslashes, change the If(vCount=2) to If(vCount=3).
Application(A1;"WordPerfect";Default) OnCancel(End@) vCount:=0 Type("\")
// If the character to the left
is a backslash (i.e., ASCII 92) - IF(CTON(?LeftChar)=92)
// Go backwards and count number
of backslashes While(CTON(?LeftChar)=92) PosCharPrevious() vCount:=vCount+1
Endwhile
// Return to original position ForNext(x;1;vCount;1) PosCharNext()
EndFor
If(vCount=2) ForNext(x;1;vCount;1)
DeleteCharPrevious() EndFor
HardReturn() FileSave() Endif
ENDIF Label(End@) Quit // - - - Macro code ends here
- - - |
TIP
3
|
Click
here for a macro that uses the ` key (next to the "1"
key) to play a macro when the ` keys is pressed twice in succession.
This "double-strike" macro example deletes multiple
spaces at the cursor location and then inserts a Tab. |
TIP
4
|
Automatically expand QuickCorrect
abbreviations to create possessives by "double-tapping"
the single quote mark key ('). For example, if you have a QuickCorrect
entry "pf" that expands to "plaintiff" when
you press the spacebar, you can make it expand to "plaintiff's"
with this technique. Here's how.
When the macro below is assigned
to the normal single quote key (see more, below), pressing the
single quote key the first time makes the macro's "Else"
condition true (i.e., there's no single quote on the left), and
the macro simply inserts a single, straight (non-typographical)
quote mark at the cursor location.
Pressing the single quote key
once more makes the "If" condition true (i.e., there
now is a single quote on the left of the cursor). The macro then
immediately types a space, then deletes the space. A space character
enables QuickCorrect entries to expand. You can then type an
"s" to created the possessive of the previous (now
expanded) word.
Notes:
If QuickCorrect is turned OFF
(Tools, QuickCorrect, Replace words as you type), the macro will
pop up a message.
The typographical version of
the single quote (the symbol (4,28), which has the numerical
value of 1052) used below is the same one normally used in QuickCorrect's
SmartQuotes tab. If you use a different SmartQuote for the single
quote mark, you need to change the command below to match it.
(Most users will not need to do this.)
// Macro code
begins
// Check if the item to the left
is a single quote text character,
// or if it is a WP symbol (a typographical quote mark (symbol=4,28)):
If(CToN(?LeftChar)=39 or CToN(?LeftChar)=1052)
If(?QuickCorrect=False) // Display a message -
DeleteCharPrevious
// Delete the quote mark // The Messagebox() command
should be all on one line -
Messagebox (;"DoubleTap.wcm";
"QuickCorrect is currently OFF."
+NToC(0F90Ah)+NToC(0F90Ah)+
"Turn it ON to expand QuickCorrect
entries with"
+NToC(0F90Ah)+ "Tools, QuickCorrect,
'Expand words as you
type.'" ; IconInformation!)
Go(End@)
Endif
Type(" ") // <= Enter a space character
DeleteCharPrevious
Else
Type("'") // <= Enter a straight, single quote
between double quotes
Endif
Label(End@)
// Macro code
ends
Assign this macro
to the single quote key
|
Click Tools, Settings, Customize,
Keyboards tab. Select the keyboard you want to modify. (Or click
Copy to make a copy of it first: In the Copy Keyboard window,
select the keyboard to copy, click Copy, and Rename the
object with a new name, then click OK. Left-click the new
keyboards name and click Select to use it.) Next, in the
Customize Settings window, click Edit to edit the keyboard definition.
Check the box "Allow assignment of character keys".
In the left window, scroll down
to the single quote (it's just after the ampersand, "&")
and select it, then click Remove Assignment if there already
is an assignment. In the right-hand window, click the Macros
tab and then Assign Macro to Key. Select the macro from the file
directory, and click OK, then Close until you are back in your
document.
You might also want to assign
the single quote keystroke to, for example, the '+Alt keys. In
the event you need a single quote and the macro is not available
(such as when editing a macro), this "backup" assignment
might come in handy. |
|
|