|
|
|
July 1999: How to maintain multiple macros for various WP versions with one source macro
Another version of WordPerfect has just become available, and many people in your organization have upgraded. But you still have users who are using older versions of WordPerfect. Now making changes to your macro systems will be a nightmare, right? Not necessarily. There are a few tricks you can follow that allow you to keep just one version of the macro source code, yet be able to distribute versions of your macros that are compiled for the various versions of WordPerfect that you need to support. The trick is to keep one copy of the source macro, and name it so that the filename extension is .SRC, rather than .WCM. It doesn't really matter what the extension is, but naming it with .SRC helps you keep it straight from the macros you will actually be distributing, which will have the .WCM extension. You'll also need to create a separate macro for each version of WordPerfect that you need the macro to work in. This macro will be the one you distribute, but it won't actually contain any of the source code for the macro. It will just INCLUDE the source code from the .SRC macro. Each of the distributable macros should have a header describing what it does, what version it is for, and who to contact in case of trouble or questions. The distributable macro should also include a warning to the user not to open and save the macro, since this will make the macro unusable. And finally, this macro will contain a line of code that references the .SRC macro. When the distributable macro is compiled, the machine code portion of the source macro will be copied into the distributable's prefix.
Here's an example of the header that should be placed in the distributable macro:
Once you have your source macro finalized, you'll compile both the source and the distribution macro in the appropriate WP version. When this distribution macro is compiled, the .SRC macro will be stored in the prefix of the distribution macro. You can then distribute just the distribution macro to your users. You need not distribute the source macro. So, even though you must still compile a macro for each version, you only have one source macro to maintain in case changes are required down the line. Sometimes, you'll need different code for a particular function in the different versions of WordPerfect. For example, you may be using a DLL call from WordPerfect's Shared Code. Unfortunately, the Shared Code DLL filename changes with each version of WordPerfect. You can still maintain just one macro by using a system variable to test which version of WordPerfect is being used.
When you run a macro with code that tests the version, only the correct code for that version will be executed. Having to maintain only one source macro will help keep your life from getting to confused and hectic at times. You may find that you want to use this strategy even if you only need to support one version of WordPerfect.
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 1999 by J. Jeppson. |