PerfectScript Journal
 

December 1997 Macro Q&A 

Removing extra hard returns  
Q. I have several documents that have more than two hard returns after each paragraph. The number of hard returns is not consistent. I want just two hard returns after each paragraph of text, so I must remove the extra ones. How can I search for multiple hard returns and remove all but two of them with a macro?  

A. The WHILE command is the best way to tackle this problem. The following macro first searches for 2 hard returns and places the cursor after them. It then uses WHILE and a system variable to check whether the next code is a hard return. If it is, it deletes it. It continues to delete hard returns until a different code or character is reached. Then it searches for the next occurence of two hard returns and starts over. Once there are no more hard returns, the macro stops.

PosDocTop()
ONNOTFOUND(end)
LABEL(top)
SearchString("[HRt][HRt]"
MatchPositionAfter()
SearchNext()
WHILE(?RightCode = 204)
   DeleteCharNext()
ENDWHILE
GO(top)
LABEL(end)
MessageBox(; ; "Done!")
          

To insert the two [HRt] codes in the SearchString command, click the Codes button on the Macro Toolbar, then select [HRt] from the codes list.

Additional information about system variables and the WHILE command can be found in my book.


Converting macros from WP 5.1 to WPWin 6/7/8 
Q. My company will be converting from WordPerfect 5.1 to version 8 soon. We have extensive macros that we use to process our documents. Is there a conversion utility we can use to convert our macros?

A. There is a conversion utility that shipped with WP 6 that will convert WP 5.1 macros. This utility is called mcv.exe. Unfortunately, the utility only works acceptably on the very simplest macros, namely those that only type text.

You'll save time and money by just rewriting your macro system rather than tring to convert. Your old macro system is based on very old technology. Many of the things that you had to write special routines for in WP 5.1 macros can be done with a single command in WPWin, and in some cases, those special routines won't be needed at all.

So learn how your new version of WP works, determine how you would go about accomplishing the required tasks in the new software, and go from there in creating a new macro system.

If the task is too daunting, there are news groups on the Web where you can get help. Corel sponsors several. You can get to them from book to help you learn about the new macro language.


If you have a question about PerfectScript or WordPerfect for DOS macros, you may submit it may emailing me. Include the words PSJournal-Question in the Subject line.

Sorry, I can't publish or acknowledge all submissions. All submissions become the property of PerfectScript Journal.

 

 

Copyright Notice: The information included in the PerfectScript Journal is protected by US Copyright. The author grants you the right to use the routines in your own macros as needed. You may not sell, distribute, or publish them in any form.
If you choose to use the information here, you do so entirely at your own risk. No representations are made regarding the fitness of this information for your   particular purpose, or for your ability or inability to use the information. You   are advised to make backups of all relevant files before implementing any suggestion  or technique.
© Copyright 1997 by J. Jeppson.