Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate |
Barry MacDonnell's Toolbox for WordPerfect |
||
Macros, tips, and
templates for Corel® WordPerfect® for Windows® |
Page updated Dec 11, 2020 |
|
About that optional 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 option: □ Use WordPerfect 9 text selection [abbreviated here as "WP9TSS"] If you have left that WP9TSS box unchecked ("OFF") — which is the WordPerfect installation default — then WordPerfect 10 and later versions 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 default WP9TSS setting ("OFF") 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 to some newer (WP10+) macros. (Sample compensation code can be found below.) |
|
Some examples of the problem . . . |
|||
|
Some examples illustrate the way WP10-WPX9 (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 WordPerfect 10 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 program default), it appears from reports that it will count the end of the paragraph, the next hard return, and then begin counting again in the next paragraph. In this imaginary example, the OFF setting will affect the count because an accurate count with this macro 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"), existing 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 WordPerfect 10 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.) Tip
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" setting.
• 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) // [1] Place
these next commands at the top of
// the macro after any Application() command: vPrefFlag:=0
If (?WP9Selection= False) PrefEnvironment (WP9Selection:On!) vPrefFlag:=1 EndIf // ... 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!) // [2] Place these If..Endif commands
at the end --
// i.e., wherever your macro might exit -- and where you // wish to restore the previous WP9 text selection setting: If (vPrefFlag=1)
PrefEnvironment (WP9Selection:Off!) Endif // ... 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!) // ... Exit your macro with Return or Quit: Quit Example #2 (useful if your macro might be played in any version of WordPerfect up to version 25) // [1] Place these next 2 commands at the top of // the macro, after any Application() command:
Global vWP9State=""
SetWP9SelectionState ("On") // ... 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!) // [2] Place this command
at the end --
// i.e., wherever your macro might exit // -- and where you wish to restore the // previous WP9 text selection setting: SetWP9SelectionState ("Restore")
// ... 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!) // ... Exit your macro with Return or Quit: Quit //
[3] Typically you should place the next segment at the end of
// your macro after all other code. When executed, it will return // to where it was called. // Note the use of IfPlatform..EndIfPlatform. These commands might need
Procedure SetWP9SelectionState(cmd) // IMPORTANT -
// The ElseIfPlatform()) is a single command, so it should "wrap" at // the margin and NOT contain any internal hard returns (HRt):
ElseIfPlatform(_Version11!;_Version12!;_Version13!;_Version14!;_Version15!;_Version16!; Comments • These code snippets can be added to
older ("legacy") macros that will be played in WordPerfect 10
(or 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 25 (presumably to be released in 2025). They probably can be extended even 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. Decision point: 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. |
|||||||||||||||||||
|
Summary: 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 macro's code. The code checker macro's list can help save you some time when examining your macro's code for proper operation under WP10+ and it should tell you if your 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. |
||||||||||||||||||||
Footnote 1 [Continued from above...] 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 [c.1999] 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. Footnote 2 [Continued from above...] 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). Footnote 3 [Continued from above...] The use of compound IfPlatform..EndIfPlatform commands to pertain to a range of possible WordPerfect versions -- such as used in macro Example #2 above -- was based on an old post on WordPerfect Universe. While the macro works fine, it will require occasional updating to account for new version numbers (post-version 25, if such exists). However, here's a undocumented macro command parameter in IfPlatform -- an added underscore character -- that seems to work well to more briefly and permanently identify the current version as a member of a set of WordPerfect versions (or as NOT a member). Macro writers might wish to explore it in their own macros: Examples (these are snippets of code -- NOT a single macro!) // PURPOSE:
// Tests the open WordPerfect (major) version number using // the IfPlatform, ElseIfPlatform, and EndIfPlatform commands // [other macro commands within these commands only compile // if they are compiled on the version(s) specified in IfPlatform()] // = = = Snippet #1: // = = = Tests if version is LESS than 20 (i.e., WP 2020): // = = = Note the _underscore before the "!" mark IfPlatform(_Version_! < 20) Messagebox(;;"This WP version is earlier than 20") ElseIfPlatform Messagebox(;;"This WP is version 20 or later") EndIfPlatform // = = = Snippet #2: (see Example 2 above for a range of versions) // = = = Tests if version is EITHER 19 or NOT 19 (i.e., WPX9): // = = = Note there is NO underscore before the "!" mark IfPlatform(_Version19!) Messagebox(;;"This WP version is 19") ElseIfPlatform Messagebox(;;"This WP version is NOT 19") EndIfPlatform // = = = Snippet #3: // = = = Tests if version is GREATER than 15 (i.e., WPX5): // = = = Note the _underscore before the "!" mark IfPlatform(_Version_! > 15) Messagebox(;;"This WP version is later than 15") ElseIfPlatform Messagebox(;;"This WP is version 15 or earlier") EndIfPlatform // = = = Snippet #4: // = = = Tests if version is GREATER than or EQUAL to 19: // = = = Note the _underscore before the "!" mark IfPlatform(_Version_! >= 19) Messagebox(;;"This WP version is 19 or later") ElseIfPlatform Messagebox(;;"This WP version is earlier than 19") EndIfPlatform // = = = Snippet #5: // = = = Tests if version is LESS than or EQUAL to 15 -and- // = = = Tests if version is GREATER than or EQUAL to 18: // = = = Note the _underscore before the "!" marks IfPlatform(_Version_! <= 15) Messagebox(;;"This WP version is 15 or earlier") ElseIfPlatform(_Version_! >=18) Messagebox(;;"This WP Version is 18 or later") EndIfPlatform // Then do more things if the current macro is ONLY version 16 or 17... |