|
|
|
April 1999: Stripping the Source Code from a
PerfectScript Macro You worked hard developing your macro. Then you distributed it to users in your company. Later you get a phone call from a user who can't get the macro to work properly. After 3 hours of troubleshooting, you find that the user edited the macro and accidentally deleted a crucial parenthesis, or changed a path, or changed something else that they should not have changed in the macro's source code. You can prevent users from tampering with your source code (or your competitors from stealing your source code) by stripping the source from the distributed macro. You don't need any special utilities or knowledge to do this. You can just use tools already provided by PerfectScript. Stripping a macro also cuts the file size in half when the source code is stripped. So it is a good idea to distribute a stripped macro when space is limited, also. As with most things in WordPerfect, there is more than one way to strip the source code. I will present two methods here. Method #1: Use the INCLUDE commandThis is the method that I prefer because I can add text at the top of the distributed macro to warn curious people not to open, then save the macro. First, create your macro and give it the filename extension .SRC rather than the standard default .WCM extension. This helps you keep the source code file separate from the distribution file. Next, create a second macro with the same name as the "real" macro, but use the .WCM extension. In that macro, place a header with any information you like, and an INCLUDE command that includes the "real" macro. I like to include comments that provide a description of the macro, the developer name, a copyright statement, a revision date, and the instructions, in highly visible letters, instructing the user that saving the macro will destroy it.
// *****************************************************
// Description: This macro does .....
// Developer: J. J Wright
// Copyright 1999 All Rights Reserved
// Revised: April 7, 1999
// DO NOT OPEN, THEN SAVE THIS MACRO
// DOING SO WILL DESTROY IT
//********************************************
INCLUDE("mymacro.src")
This macro should be stored in the same directory as the "real" macro. When you compile this distribution macro, the part of the "real" macro that does all the work will be included, but the source code will not be. You can then distribute this macro, giving users all the functionality of the real macro, but none of your source code goes with it. Method #2: PerfectScript's Strip FeatureThe second method for stripping source code is contained in PerfectScript itself. This method is available in PerfectScript 8 (and probably 9), but not in version 6.x or 7. Be careful when using this method, because your actual macro will be modified. The utility DOES NOT automatically make a copy of your original macro. The first step is to make a copy of your macro, so that you don't lose the source code altogether. Again, I suggest that you name your "real" macro with a .SRC filename extension, then make a copy of it, changing the filename extension to .WCM on the copy before attempting to strip the source code. Once you have your copy, start PerfectScript. Click File > Remove Source from the menu. At the Remove Source dialog, select the .WCM version of your macro, then click Remove. You will be prompted with a dialog asking for confirmation that you want to permanently remove the source ccode. If you are sure you do, click Yes. You can then distribute the stripped macro. Keep in mind that a macro stripped with this method will contain no comments that warn the user against opening and saving the macro. It will appear as just a blank file to prying eyes.
For information on ordering my book see my web page. 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. |