@program mutateprop.muf
1 9999 d
i
( mutateprop.muf version 1.0 by Wog

A program to allow mass-changing of a property throughout the database.
To use link an action this program and use it as in:
<action> property=oldvalue:newvalue
The program will scan the entire database for all examples
of property set to oldvalue and change them to newvalue.

--- Change History ----------------------------------
v 1.0	Aug 29 2000
    Initial Release
        23 Feb 2001
    Minor updates for release on webpage.
--- Distribution Information ------------------------
Copyright {C} Charles "Wog" Reiss <car@cs.brown.edu>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or {at your option} any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

For a copy of the GPL:
   a> see: http://www.gnu.org/copyleft/gpl.html
   b> write to: the Free Software Foundation, Inc., 
     59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
)
lvar prop
lvar from
lvar to

: checkprop ( d -- )
	dup prop @ getpropstr from @ strcmp not if
		prop @ to @ setprop
	else pop then
;

: loop
	dbtop int
	begin
		1 - dup 0 >= while
		dup dbref
		checkprop
	repeat pop
;

: main ( "prop=from:to" )
	"me" match me !
	me @ "W" flag? not if "Permission denied." .tell exit then
	dup if
		"=" .split ":" .split
		to ! from ! prop !
	else pop
		"Enter property name: " .tell
		read prop !
		"Enter value to mutate from: " .tell
		read from !
		"Enter value to mutate to: " .tell
		read to !
	then
	"Mutate property '" prop @ strcat "' from '" strcat from @ strcat
	"' to '" strcat to @ strcat "'? Enter YES, all capitals to confirm." strcat .tell
	read
	"YES" strcmp not if
		">> Performing mutation.. Please wait..." .tell
		loop
		">> Done." .tell
	else
		">> Cancelled." .tell
	then
;
.
c
q
@set mutateprop.muf=VIEWABLE
@set mutateprop.muf=W
