I have another handy program called TEXTEDIT, it takes a text file as input. PPWIZARD can simplify handling of any text file and this example shows how I have used it to create some "macro" commands that not only simplifies the syntax but checks the return code (TEXTEDIT aborts on error).
The code shown here is a small fragment of what I use to completely automatically extract menus, dialogs etc out of Netscape and modify or delete controls, then put the modified resources back into Netscape.
;-------------------------------------------------------- ;--- Edits dialog 102 of Netscape 4.04 "Communicator" --- ;-------------------------------------------------------- ;--- Include header file ---------------------------------------------------- #include "DIALOG.H" ;--- Disable Choose file button --------------------------------------------- <$DisableControlLineGivenMiddle LINE=^<$DLG_CHOOSE_FILE>^> ;--- Disable "Composer" radio button ---------------------------------------- <$DisableControlLineGivenMiddle LINE=^<$DLG_COMPOSER>^> ;--- Thats all Folks! ------------------------------------------------------- <$WriteFile>
;--- Include generic stuff -------------------------------------------------
#include "TEXTEDIT.H"
;--- Constants -------------------------------------------------------------
#define DLG_CHOOSE_FILE Choose ~File
#define DLG_COMPOSER ~Composer
;--- Disable Control -------------------------------------------------------
#define DisableControlLineGivenMiddle \
ReplaceLines {$COUNT="1"} ^*{$LINE}*^ ^${ReplacedLine}, WS_DISABLED^ %\
<?Hash>if '${Rc}' <> '0' %\
@exit 255 'Could not find a control line matching = "*{$LINE}*"' %\
<?Hash>endif
;--- Macro to delete a line ------------------------------------------------
#define DeleteLineGivenMiddle \
DeleteBlock ^*{$LINE}*^ ^*{$LINE}*^ %\
<?Hash>if '${Rc}' <> '0' %\
@exit 255 'Could not find a line matching = "*{$LINE}*"' %\
<?Hash>endif
;--- Write changed data to file --------------------------------------------
#define WriteFile \
;--- Pretty up the final code (easier to read) --- %\
top %\
ReplaceText 9999 "BEGIN" "{" %\
ReplaceText 9999 "END" "}" %\
-\
;--- Write the file ------------------------------ %\
checkpoint
;--- Find a line -----------------------------------------------------------
#define MustFindLineGivenMiddle \
Find {$COUNT="1"} ^*{$LINE}*^ %\
<?Hash>if '${Rc}' <> '0' %\
@exit 255 'Could not find a line matching = "*{$LINE}*"' %\
<?Hash>endif