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®
© Copyright 1996-2017 by Barry MacDonnell. All Rights Reserved.

Page updated Jun 1, 2013

A new feature introduced by Corel® in WordPerfect 10 (and present in all later versions) ...

  • affects the way text is selected ...
  • affects the way the cursor moves ...
  • and it can cause serious problems with macros!
   

If you are using WordPerfect 10 or later version, click on Tools, Settings, Environment. You'll see a new option there:

"Use WordPerfect 9 text selection" (abbreviated here as "WP9TSS")

If you have left the WP9TSS unchecked -- which is the WordPerfect installation default -- then WP10-WPX6+ will treat word selection and cursor movement somewhat the way Microsoft Word does. (Examples below.)

This is more than a mere "Microsoft compatibility" issue: The WP9TSS can also 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 . . .

 
Text selection problems

Some examples illustrate the way WP10-WPX6 (and probably future versions) will select words if you leave WP9TSS unchecked (i.e., OFF).

Example 1: If you use your mouse to select a word to be underlined, you'll notice that WP10+ will also underline the trailing space after the word, like this . This is how many WP10 users first discovered the existence of the new, poorly documented, and unannounced WP9TSS.

Note that underlining spaces is primarily controlled in WordPerfect by the "Text & Spaces" setting in Format, Font, Underline [tab]. If Text & Spaces is enabled, you'll get underlined spaces, which is preferred by most people -- except for trailing spaces, which is generally not desirable.

Example 2: The following demonstration macro was posted on the Corel WP10 newsgroup on 8/17/01. It is supposed to convert the selected word to a word with initial capitalization. One of the C_Techs confirmed that the macro works properly with the WP9TSS turned ON; otherwise, it fails to work properly and apparently converts the following word, too!

Application (WordPerfect; "WordPerfect"; Default!; "EN")
SelectWordNext ()
ConvertCaseInitialCaps ()
SelectMode (State: Off!)

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.)

Update (5/28/08): There appears to be an undesirable interaction between this new feature and the Tools, QuickWords option, "Expand as plain text." See Footnote 2 below.

 
Cursor movement problems

With respect to certain cursor movements, Charles Rossiter, a C_Tech, wrote in the Corel WP10 newsgroup:

"...Try doing Ctrl+Right Arrow [in WP10] towards the end of a paragraph. With WP9 Text selection [turned on to emulate WP9 and earlier versions], the cursor jumps from word to word, even over the paragraph break. Without WP9 text selection, at the paragraph break, the cursor jumps to the end of the line, and then after the next hard return and then to the start of the next paragraph....This has severe effects on any macros which use [the] PosWordNext [command]...."

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.  
Using macros in WordPerfect 10 - WordPerfect X6+ that were written in earlier 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 -
PosWordNext
PosWordPrevious
PosParagraphNext
PosParagraphPrevious
SelectWord
SelectWordNext
SelectWordPrevious
SelectSentence
SelectSentenceNext
SelectSentencePrevious
SelectParagraphNext
SelectParagraphPrevious
...and (possibly)...
DeleteWord
SelectOn
SelectOff

- 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.)

Light bulb Tip: You can download a code-checking macro here (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 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-WPX6+ that was written in a previous ("legacy") verion of WordPerfect:

Playing a LEGACY MACRO in
WordPerfect 10 - WordPerfect X6 (and possibly later versions)
... with WP9TSS "on" during playback  ... with WP9TSS "off" (the shipping default)
The macro should play OK (WP10-WPX6+ should act like WP9, WP8, etc.). The macro may have problems if the above-mentioned commands are present, especially if the code was written with their specific (pre-WP10) actions in mind; corrections are highly recommended to ensure the macro plays in WP10+ the same way it was recorded/written.

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."

 
Using macros in WordPerfect 10 - WordPerfect X6+ that were written in those versions

Any new (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:

Playing a NEWLY WRITTEN MACRO in
WordPerfect 10 - WordPerfect X6 (and possibly later versions)
... with WP9TSS "on" during playback, and ... with WP9TSS "off" (the shipping default) and
... if WP9TSS was "on" during macro's creation ... if WP9TSS was "off" during macro's creation ... if WP9TSS was "on" during macro's creation ... if WP9TSS was "off" during macro's creation
The macro should play OK (same conditions, same WP version). The macro may have problems if the above-mentioned commands are present, especially if the code was written with their specific actions in mind; the code should be examined to see if corrections are required (the writer may like the way the new text selection and cursor movement methods work, and setting the WP9TSS to "on" may be undesirable). The macro may have problems if the above-mentioned commands are present, especially if the code was written with their specific actions in mind; corrections are highly recommended to ensure the macro plays the same way it was recorded/written. The macro either plays OK (same conditions, same WP version) or it doesn't (e.g., if it uses a word count routine that uses one of the above cursor-positioning commands the count could be wrong if, say, hard returns between paragraphs are also counted); the code should be examined to see if correction routines are required (the writer may like the way the new text selection and cursor movement methods work, and no correction may be desirable).

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 . . .

Sample macro snippets

The following macro code can be copied into your WordPerfect program and compiled as a regular macro to test its effects on the new "Use WordPerfect 9 text selection" setting. 

It simply displays three prompt messages to allow you to check the setting in Tools, Settings, Environment during the macro's progress. [If you need instructions on how to copy/compile the code, see here. The original snippet was written by macro guru Klaus Pfeiffer and uploaded on WordPerfect Universe here. Thanks, Klaus!]

Then, after testing it, copy just the code segments shown in dark red into your own macros, at the locations indicated.

Notes

These macro 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 restores it to its previous state when the macro exits.

The snippets are also useful in newly written macros (i.e., written in WP10 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 below in the ElseIfPlatform segment.]

The snippets should work up through WordPerfect version XX (i.e., v20). It probably can be extended further into the future with additional "_versionNN!" parameters in the ElseIfPlatform() command.



// Lines written in black are simple examples or ordinary macro code. Lines in dark red are the operative code snippets.
// Here, Prompt commands are used to tell the user what is going on while demonstrating the effects. For example:
Prompt("";"Note the current state of 'Use WP9 text selection' in Tools, Settings, Environment (it can be ON or OFF), then click OK." ;Pause!)


// Place these commands at the top of your 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!)

// 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:
Return 

// 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:
Procedure SetWP9SelectionState(cmd)
IfPlatform(_Version10!) // (version 10 did not have the ?WP9Selection variable; see below)
 If(cmd like "On")
   vWP9StateKey="Software\Corel\Shared Settings\"+?MajorVersion
   hRegKey=RegistryOpenKey(CurrentUser!; vWP9StateKey)
   If(hRegKey=0)
     MessageBox(;"Error: Open Registry!";vWP9StateKey; IconExclamation!)
     Return
   EndIf
   vWP9State=RegistryQueryValue(hRegKey;"Use WordPerfect 9 style selection")
   RegistryCloseKey(hRegKey)
   PrefEnvironment(WP9Selection: On!)
 Else
   PrefEnvironment(WP9Selection: vWP9State)
 EndIf
ElseIfPlatform(_Version11!;_Version12!;_Version13!;_Version14!;_Version15!;_Version16!;_Version17!;_Version18!;_Version19!;_Version20!)
 If(cmd like "On")
   vWP9State=?WP9Selection
   PrefEnvironment(WP9Selection: On!)
 Else
   PrefEnvironment(WP9Selection: vWP9State)
 EndIf
EndIfPlatform
EndProc


Backward compatibility in newly written WP10-WPX6+ macros

If you include the code snippets above in a newly written WP10-WPX6+ 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 WP10-WPX6+ 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 WP10-WPX6+ 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, WP10-WPX6+ 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. The decision, like your implemtation of the techiques here, is your responsibility.

Some things worth remembering

In 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 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 the 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.

 

Notes . . .

 

Footnote 1

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!). Be aware that the macro will not compile in earlier builds of WP10 because the 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 sample macro above if there is a chance the macro might be used in those earlier builds.

Footnote 2

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).
2. Enable "Use WordPerfect 9 text selection" in Tools, Settings, Environment.
3. Reboot WordPerfect (optional, but can't hurt) and create the QuickWord(s) again.

Tips

  • 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).
 [Page Top]