TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Andrew Batiuk
from: Peter Hansen
date: 1995-06-27 11:07:00
subject: Erasing a string

In a message on 06-25-95, Andrew Batiuk said to Peter Hansen:

AB>   It seems that just spacing over the string works fine, so that
AB>would be acceptable.  I know it shouldn't be hard, 
                                   ^^^^^^^^^^^^^^^^^
It wasn't.  Enjoy :)
--------cut here-----------------------------
/***********************************************************************
 *
 *  Name:   blotesc.cmd
 *
 *          No copyright.  This program is in the public domain.
 *          (Big deal...)   
 *            
 *          USE AT YOUR OWN RISK.  Neither the author nor
 *          Engenuity Corporation assumes any responsibility
 *          for damage to your data, computer, pocketbook,
 *          or anything else as a result of your use or misuse
 *          of this program or its derivatives.  When in doubt,
 *          throw it out.  This program has NOT been thoroughly
 *          tested and you are strongly advised to make backups
 *          of your entire hard drive and those of both 
 *          neighbours before using it.  Lock your doors first.
 *          And remember: DON'T PANIC!!
 *           
 *  Desc:   BLOTESC (pronounced "blowtesque" :)
 *          This utility scans the current directory or the specified
 *          directory for files matching the pattern *.ANS.  All
 *          such files that are not read-only are examined.  If the
 *          first line contains the evil escape string that string is
 *          overwritten (blotted out..thus the name) with spaces.
 *
 *  Usage:  blotesc [dir]
 *
 *          If 'dir' is not present, current directory is used.
 *          'dir' can, but needn't, have a trailing slash.
 *
 *  Revision History:
 *  1995-06-27 -PLH=Peter L. Hansen, created this file.
 */

trace 'n'
'{at}echo off'

    /* set up variables */
fpat = '*.ans'                    /* file-matching pattern */
evil = d2c(27) || '[7h?'          /* escape, plus text */

    /* read and process argument(s) */
parse arg dpath .

    /* if no path specified (just drive), use current directory */
if dpath = filespec('drive',dpath) then dpath = dpath || '.'
if right(dpath, 1) \= '\' then dpath = dpath || '\'
dpath = dpath || fpat

    /* load library functions */
if RxFuncAdd('SysFileTree', 'RexxUtil', 'SysFileTree') = 0 then
    _abort('Unable to load RexxUtil functions')

say 'Checking for writable files that match' dpath

    /* find all matching files that aren't read-only, 
       returning name only */
if SysFileTree(dpath, 'files', 'FO', '***-*') \= 0 then
    _abort('No memory.')

if files.0 > 0 then do
    okcount = 0
    do i = 1 to files.0
        if stream(files.i, 'c', 'open') = 'READY:' then do
            line = linein(files.i)      /* read first line */
            evilpos = pos(evil, line)   /* find position of string */
            if (evilpos \= 0) then do   /* if present, overwrite it */
                say 'Overwriting string in file' files.i
                call charout files.i,copies(' ', length(evil)),evilpos
                call stream files.i, 'c', 'close'
                if result \= 'READY:' then
                    say 'Error' result 'when closing file' files.i
                else
                    okcount = okcount + 1
                end
            else do
                say 'File' files.i 'does not contain the string.'
                okcount = okcount + 1
                end
            end
        else say 'Unable to open file' files.i
        end

    if okcount = 1 then okcount = 'One file'
    else okcount = okcount 'files'
    say 'Done.' okcount 'out of' files.0 'successfully processed.'
    end
else do
    say 'No files to process.'
    end

exit 0


_abort: procedure
parse arg msg

if msg \= '' then say msg
else say 'Aborting...'

exit 1
-----------cut here---------------------

------------------------------------------------------------------------
 Peter Hansen                                     Engenuity Corporation
 Internet: peter{at}engcorp.com                    Guelph, Ontario, Canada
 WWW: http://www.sentex.net/~engcorp/peter/
------------------------------------------------------------------------
___
 * MR/2 * 

--- QScan/PCB v1.15b / 01-0348
* Origin: FidoNet: CRS Online, Toronto, Ontario (1:229/15)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 229/15 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.