| Barry MacDonnell's
Toolbox for WordPerfect
Macros, tips, and
templates for Corel® WordPerfect® for Windows®
| Page updated Jun 16, 2017
About that WordPerfect 9 Text Selection Setting . . .
A new option introduced by Corel® in
WordPerfect 10 (c. 2001) — and still present in all later versions —
▸ affects the way text is selected,
▸ affects the way the cursor moves,
▸ and as a result it can cause problems with macros!
In WordPerfect 10 or later version, click on Tools, Settings, Environment. You'll see this check box:
□ Use WordPerfect 9 text selection (abbreviated here as "WP9TSS")
If you have left the WP9TSS box unchecked — which is the WordPerfect installation default — then WP10+ will treat text selection and cursor movement somewhat the way Microsoft Word does. (Examples below.)
Presumably this was introduced to address a "Microsoft
compatibility" issue. But it has a serious side effect with macros:
The WP9TSS setting can alter the way some WordPerfect macros behave — no matter who created them! — producing unexpected effects or even incorrect results. And you might not even notice because some effects can be subtle.
To compensate for this you might need to add some code snippets to legacy macros (WP9, WP8, etc.) as well as newer (WP10+) macros. (Sample compensation code can be found below.)
|Some examples of the problem . . .
Some examples illustrate the way WP10-WPX8 (and probably future versions) will select words and some format codes if you leave WP9TSS unchecked (i.e., OFF, which is the factory default state).
While these two examples may seem trivial, the presence of extra spaces in some macros can produce completely different results when the macro plays. And you might not even notice it. (Your client or boss might, though.)
With respect to certain cursor movements, Charles Rossiter, a C_Tech, wrote in the Corel WP10 newsgroup:
Imagine a macro, for example, that must count words (say, by moving the cursor with the PosWordNext command and incrementing a counter variable). Maybe the count is meant to keep document or section size within certain limits, or maybe it's to position the cursor at a certain spot before other processing can occur. With the WP9TSS checked ON in WP10, only words are counted. With it OFF (the default), it appears from reports that it will count the end of the paragraph, the next hard return, and then begin counting in the next paragraph.
In this imaginary example, the OFF setting will affect the count because an accurate count depends on how the cursor moves over a specific block of text. Paragraph endings and hard return codes are not normally considered to be words.
An opinion . . .
|There are two broad areas of concern. The first relates to using older ("legacy") macros in WP10 and later versions. The second relates to creating new macros in WP10 and later versions for use in those versions.|
Any macros written in a version prior to WP10 that are to be used in WP10-WPX6+, and that use the very common commands of -
- should have correction/compensation code added to them (see sample snippet below).
Also, the above may not be a comprehensive list: There may be other, similar commands that should be added. (If you have found any, please contact me; the good news is that I have not yet received any reports of other commands that should be added to the list.)
You can download a code-checking macro (WP9TSS code checker.wcm in a download file, WP9TSSCC.zip) that can examine the current macro you have onscreen for editing, and create a separate listing of any of the above commands that it finds in the macro's code. The list can help save you some time when examining the macro's code for proper operation under WP10+.
Here, proper operation means the macro operation you personally expect with the new "Use WP9 text selection" switch enabled (i.e., "on"). See below for the types of effects you might find with your legacy and newly written macros.
Note that this code checker macro is not the "compensation code" macro referenced above and elsewhere. That particular macro code can be seen below. But please read on before you use it.
Here are some logical possible results of playing a macro in WP10+ that was written in a previous ("legacy") verion of WordPerfect:
Either of the sample code snippets at the bottom of this page can be added to all legacy macros as a simple precaution. Since they won't execute in a version other than WP10 due to embedded IfPlatform() commands, any legacy macro that has them can be used in both the original, earlier version of WP and in WP10-WPX6+. In effect, the legacy macro will become "WP10-WPX6+ aware."
Any newer (WP10+) macros should be examined to see if they are working as expected in WP10+ under the two possible states (ON and OFF) of the WP9TSS. Obviously the initial state of the WP9TSS when the macro was first written or recorded can be later changed to the opposite state by any user, thereby inadvertently modifying the macro's behavior. This can produce unpredictable results, whether obvious or not, with macros that contain the above commands. (And I am not certain if any other macro commands are affected!) Here are some logical possible results of playing a macro in WP10-WPX6+ that was written in a previous verion of WP or one that was written in WP10-WPX6+ itself:
Such macros are strong candidates for correction code, such as that found below, to force them to behave as they would have behaved in WP9 and earlier. Assuming, of course, that this was the intent of the writer of the new WP10-WPX6+ macros -- a very important point to consider. (The author may want to rewrite all or part of the macro code to make it perform predictably.)
To put it another way, if you include
these correction code snippets in a macro, you are tacitly assuming
that you want the macro to employ the legacy-standard method of
selecting words (i.e., to NOT include any following space), moving the
cursor (i.e., to NOT stop at the end of the line, at the paragraph
break, etc.), and so forth.
|Correction / compensation . . .
|Either of the following macro code examples can be copied
into your WordPerfect program and compiled as a regular macro to test
its effects on turning On/Off the new "Use WordPerfect 9 text selection"
• Both example macros do the same thing. As written, the examples simply display messages to allow you to check the current setting in Tools, Settings, Environment during either example macro's progress.
• Lines in dark red are the operative code snippets.
• Lines in dark blue are just examples or ordinary macro code (here, 2 prompt commnads to tell the user what is going on).
• If you need instructions on how to copy/compile the code, see here.
Which example is "best"?
Example #1 is for WordPerfect 11 and later -- it contains a macro command (?WP9Selection) that was introduced in that version; see Footnote 1. Hence it is more brief and elegant than Example #2.
However ... if you decide to include the "Use WordPerfect 9 text selection" setting in your own macro AND that macro might be used in any pre-WP11 version (or any later version, for that matter, where the setting is needed), you probably should use the code in Example #2 because it will not execute unless it can execute in a given version. See the comments just below the examples. Additionally, the code in Example #1 would cause an error message if it was included in a macro played in (e.g.) WordPerfect 8 or 9.
After testing these examples:
Copy just the code segments shown in dark red into your own macros at the locations indicated in the macro comments.
Example #1 (for WordPerfect 11 and later versions)
// Place these next command lines at the top of the
// macro, after any Application() command:
// (SOME SAMPLE CODE:) ... Other macro commands can go here ... for example:
Prompt("";"Now note the current state of 'Use WP9 text selection' in Tools, Settings, Environment (it should be ON), then click OK." ;Pause!)
// Place these commands at the end -- i.e., wherever your macro might exit
// and where you wish to restore the previous WP9 text selection setting:
// (SOME SAMPLE CODE:) ... Other macro commands can go here ... for example:
Prompt("";"Finally ... note the state of 'Use WP9 text selection' in Tools, Settings, Environment (it should be reset to the first state), then click OK." ;Pause!)
// (REQUIRED FOR MANY MACROS:) ... Exit your macro with Return or Quit:
Example #2 (useful if your macro might be played in any version of WordPerfect up to version XXV (i.e., version 25))
these next 2 commands at the top of the
// (SOME SAMPLE CODE:) ... Other macro commands can go here
... for example:
// Place this command
at the end -- i.e., wherever your
macro might exit
// (SOME SAMPLE CODE:) ... Other
macro commands can go here ... for example:
// (REQUIRED FOR MANY MACROS:) ... Exit your macro with Return or
Typically you should place the next segment at the end of your macro
• These code snippets can be added to older ("legacy") macros that will be played in WordPerfect 10 (and later), to help make those macros work as they did in the earlier version (i.e., WP9 and earlier) by temporarily enabling this setting if it is not already enabled, then restoring it to its previous state when the macro exits.
• The snippets are also useful in newly written macros (i.e., written in WP11 and later versions) where you need the WP9 text selection state turned "On" for proper macro function. [See also the Footnote 1 below about a new system variable, ?WP9selection, that can also be used when writing your own code. The variable was used above in Example #1 and in the ElseIfPlatform segment in Example #2.]
• The snippets in Example #2 should work up through WordPerfect version XXV (i.e., version 25). They probably can be extended further into the future with additional "_versionNN!" parameters in the ElseIfPlatform() command. [The original snippet in Example #2 was written by macro guru Klaus Pfeiffer and uploaded on WordPerfect Universe here. Thanks, Klaus!]
If you include the code snippets above in a newly written WP11 (and later version) macro you are tacitly assuming that you want the macro to employ the legacy-standard method of selecting words (i.e., to NOT include any following space), moving the cursor (i.e., to NOT stop at the end of the line, at the paragraph break, etc.), and so forth.
If you don't use these snippets and you write the WP11+ macro by recording text selections and cursor movements, the macro will naturally behave in the manner dictated by the then-current "Use WP9 text selection" setting in Tools, Settings, Environment. Later, if the user changes this setting, the macro could produce erroneous results (whether obvious or not).
There are several issues to confront here:
• What happens if a user later changes the WP9 text selection setting to the opposite of the one used during recording (or manually coding) the macro?
• What happens if you want to use the macro with an earlier version of WP?
• What happens if you add the code to a WP11+ macro long after it was recorded or written, and you're not sure of the original state of the WP9 text selection setting? Unless you deliberately set the WP9 text selection ON before recording the macro, you probably wouldn't want to blindly add these procedures to the macro later, or you might get different results, depending on the purpose of the macro code. Examine the code to be sure.
Therefore, before using this code in a new, WP11+ macro you should first decide the issue of backward compatibity as well as issues of text selection methods and cursor movement behaviors your users expect. You may not need the code at all, or you may decide it is necessary to make your macro perform in expected ways.
This decision, like your implemtation of the techiques here, is your responsibility.
Some macros -- old or new -- played in WP10 (and later versions that use the WP9TSS switch) will behave differently in how they select text and move the cursor over words, depending on the current state of the WP9TSS switch.
In particular, if pre-WP10 macros contain the commands listed at the top of this page (PosWordNext, SelectWord, etc.), you probably should use one or the other of these macro code correction procedures.
At the very least, such procedures can give a consistency to macro playback, particularly if they were written under an earlier version of WP or were written under WP10+ with the WP9 text selection setting enabled ("on").
If they were written under WP10+ with the setting "off," you should carefully examine the macro's playback under both of the setting's states, since a user could have switched this setting and thus (possibly) affect the macro's operation. You will want to plan for this and add whichever correction procedure(s) seems most appropriate.
|Conclusion . . .
Long-time WordPerfect users who have upgraded to WP10 or a later version probably have discovered that they should enable (i.e., check) the WP9TSS in the Tools, Settings, Environment dialog. Otherwise, text selection and cursor movement will default to the "Microsoft way."
More importantly, anyone who uses
WordPerfect macros in WP10 or later version is faced with the issues
outlined above. Simply put, do not use macros under WP10 or later
version "as is." They may work okay, but to be certain you
can open them for editing and play the code-checking macro (WP9TSSCC.zip on them to create a separate
list of any of the above problematic commands that it finds in the
The code checker list can help save you some time when examining the macro's code for proper operation under WP10+ and it should tell you if the macro needs compensation code. Feel free to add the compensation code snippets in WP9TSS.zip to any macros that contain these problematic commands.
Note that downloadable macros available on the Toolbox for WordPerfect already have such compensation code included in them if the author felt the code was needed.
Note also the disclaimer here, which is particularly appropriate for users of WP10 and later versions.
|* * *
WordPerfect 10's Service Pack 2 (WP10/SP2, or build 10.0.0.663) implemented a new system variable, ?WP9Selection, which returns "0" (False) if the user has turned off the WP9TSS and "1" (True) if it was turned on. For example:
Messagebox ( ; "WP9 text selection state (T/F)" ; ?WP9Selection)You can use it to store the current state of the WP9 text selection switch and, at the end of the macro, return it to the user's preferred state with PrefEnvironment (WP9Selection: On!) or PrefEnvironment (WP9Selection: Off!). See Example #1 above for some code with a bit of conditional logic in it.
Be aware that such a macro will not compile in WP9 and earlier or in earlier builds of WP10 because the ?WP9Selection variable doesn't exist in either the initial build of WP10 or in Service Pack 1, so you should use something like the code structures in the Example #2 macro above if there is a chance the macro might be used in those earlier builds.
There appears to be an interaction between the Tools, Settings, Environment, "Use WordPerfect 9 text selection" setting and the Tools, QuickWords option, "Expand as plain text." If the former setting is disabled (the Corel shipping default) and latter setting is enabled when you create a new QuickWord entry, then an extra hard return might be inserted later in the expanded QuickWord when you type its abbreviation in a document.
This seems to depend somewhat on the way the material is selected before it is used to create the QuickWord. Rebooting WordPerfect after creating the QuickWord does not help, nor does enabling "Use WordPerfect 9 text selection" during the session (even if followed by a reboot of WordPerfect). In these cases the problem QuickWords were already created with the bug in them.
The only way I have found to fix the problem:
1. Delete the problem QuickWord(s).
• Perhaps Charles Rossiter's free QWManage.wcm macro (included in his download archive here) can help with step #3 if you use it to create a list of all your QuickWords before deleting all the problem QuickWord entries (step #1). The macro produces a two-column table with each row containing the QuickWord abbreviation and its expansion. Edit the ftable if necessary. You can then exit WordPerfect and rename the QuickWord template (e.g., rename QW13EN.WPT [for WordPerfect X3] to QW13EN-BACKUP.WPT) to back it up, and WordPerfect will create a new, empty one when you next start WordPerfect. Finally, reload WordPerfect and replay the macro to restore the QuickWords file.
• You can disable "Use WP9 text selection" after the problematic QuickWords have been re-created. But unless you prefer the "Microsoft way" of moving the cursor and selecting text, and you do not use macros, you might find that keeping this setting enabled is preferable. Again, for reasons why this might be true for you, especially if you use macros, see the information on this page (above).