              File patch tool 1.7 by Andreas Guenther 2004 - 2005
==============================================================================
A filter to remove, replace or insert lines/strings in a file.
Usage:
  ftool.exe filetoprocess "searchstring" "replacestring" -Option
Option: -l = replace all lines containing searchstring with replacestring.
        -s = replace all occurrences of searchstring with replacestring.
        -n = insert a new line with replacestring at linenumber = searchstring.
        -a = append searchstring to all occurrences of replacestring.
        -p = prepend searchstring to all occurrences of replacestring.

Special command:  (For MinGW)
Usage:
    ftool.exe filetoprocess.cpp "liblist"
 This sort of commandline generates a <libs.bat> in the current directory.
 The librarynames are parsed from the cpp file at lines with #pragma ... directives.
 The purpose of this optional command is to make it possible to use the GNU-
 linker with the correct libraries.

Special command:  (for compilers that needs to update the PATH)
Usage:
    ftool.exe filetoprocess "savepath"
 This creates a <spath.bat> in the current directory.
 This batchfile executes <SET PATH> with the original PATH that is saved at the start
 of the compilerbatchfile.

Special command: (to generate def and lnk files needed for STDCALL DLLs)
Usage:
    ftool.exe filetoprocess "outdef" "LETTER"
LETTER: S = Create def for Digital Mars
        V = Create def for MSVC++ Toolkit
        W = Create lnk for OpenWatcom
 This sort of commandline generates a <%filetoprocess%.def or lnk> in the current directory.
NOTE: filetoprocess is the *.bas file in this case.

This program works only with textfiles!

The second string can be a empty string. ""

The 2 string arguments must be enclosed in quotes to handle spaces correctly.

Quotes <"> and percent <%> characters must be handled special,
because quotes are removed when the commandline is processed and percent
characters are used for substitutions in batchfiles.

If a string contains quotes then <"> must be replaced with <@@>.
Percent characters <%> must be replaced with <##>.
The strings are corrected before they are used on the processed file.

Examples:
-l (replace whole lines)
   ftool.exe atextfile.txt "  a string to find" " a quoted @@string@@ to replace" -l
   this will replace lines containing [  a string to find] with [ a quoted "string" to replace].

   ftool.exe ezide.cpp "__asm{push arg}" "       __asm__(@@pushl ##0@@ : : @@r@@ (arg));" -l
   this will replace lines containing [__asm{push arg}] with [       __asm__("pushl %0" : : "r" (arg));].

-s (replace strings)
   ftool.exe atextfile.txt " AS INTEGER" "##" -s
   this will replace all occurrences of [ AS INTEGER] with [%].

-n (insert a new string)
   ftool.exe atextfile.txt "56" "new string" -n
   this will insert the line [new string] at line [56].

-a (append a string to the searchstring)
   ftool.exe atextfile.txt "to be " "continued" -a
   In lines containing the string [to be ], the new string is [to be continued].

-p (prepend a string to the searchstring)
   ftool.exe atextfile.txt "Computer" "portable " -p
   In lines containing the string [Computer], the new string is [portable Computer].