| Let us call you now | Contact Greenview Data, Inc. 1-800-458-3348 | Privacy | SpamStopsHere.com |
![]() |
Strip Trailing White Space |
|
Automation Example #1 (Strip trailing whitespace)Automating an editing/conversion task involves using a VEDIT "macro". Although VEDIT macros can be very elaborate and can often replace complex C or Visual Basic programs, we will illustrate automation with a very simple one-command macro. For this simple example, we want to strip all trailing "whitespace", i.e. unnecessary spaces and tab characters, from the end of all lines in a text file. This would be so tedious in a Word Processor that you won't even consider it. If you are a programmer, you might be able to write a non-trivial program to do this. VEDIT can do this with a single search and replace command: Replace("|W|>","",BEGIN+ALL+NOERR) VEDIT has many invocation options; several allow automatically running macros on startup. You can create a batch file, e.g. "stripw.bat", containing the following command to run VEDIT and strip all trailing whitespace from a file: c:\vedit\vpw -q -e -c'Replace("|W|>","",BEGIN+ALL+NOERR) Xall' %1 (This assumes VEDIT was installed into the "c:\vedit" directory.) (Technically, the "-q" option runs VEDIT in quiet mode without any screen display; the "Xall" command saves and exits the editor; "%1" is the syntax used in batch files to pass a filename to a program.) A better way of doing this is to place the VEDIT macro commands into a file, typically with a ".vdm" extension. Therefore, create a text file, e.g. "stripw.vdm" containing the following VEDIT commands: Replace("|W|>","",BEGIN+ALL+NOERR)
//Strip trailing whitespace (Note that VEDIT macros can be fully commented.) In this case, place the following command to run VEDIT into the batch file: c:\vedit\vpw -q -x stripw.vdm %1 With the STRIPW.BAT file, you can now easily strip trailing whitespace from a text file. For example, assuming the name of the text file is "payments.txt", at a DOS or NT prompt, simply give the command: stripw payments.txt In effect, VEDIT is used here as a utility program. Someone without any knowledge of VEDIT can obviously run the batch file. Best of all, it is fast, VEDIT can start up (invisibly), open the file, strip the trailing whitespace, save the file and exit in about 1 second. While many users might prefer a batch file, others might prefer a Windows icon. In this case, create a new icon on your desktop, possibly by copying the VEDIT icon. Rename the icon to "Strip trailing whitespace". Then right-click on the new icon and select properties. Change the "Command":" or "Target" to the full pathname of the batch file created earlier: c:\batch\stripw.bat (This assumes you saved the batch file in the "c:\batch" directory.) Then, you can simply drag and drop a text file from Explorer onto the new icon and all trailing whitespace will be stripped from it. This example just barely scratches the surface of the many ways in which VEDIT can automate your editing, conversion and file "clean up" operations. If you have any questions about automation or other aspects of VEDIT, please don't hesitate to contact us. For information regarding SpamStopsHere, our award winning spam blocker, spam filter service, please visit SpamStopsHere.com.
Please contact us with any sales or technical questions at:
|