Here are some HyperCard scripts to search and replace. They operate on all fields in a stack, unless the fields have been set to "Don't Search". There's probably a more elegant way to do this, but these work. On large stacks (1000 cards+), each substitution will take minutes, but you can use the last script to work all night through a whole list of substitutions.

Michael Watson, Meiji Gakuin University. [ go to top index | send me a message ]

Basic button script to search/replace all occurences automatically.
on mouseUp
ask "find what?"
put it into theFind
ask "replace with what?"
put it into theReplace
put "Replacing" && theFind && "with" && theReplace
set cursor to busy
find international theFind
if the result is not "" then
exit mouseUp
else
put theReplace into the foundChunk
end if
end mouseUp

Button script to search/replace, checking each time
on mouseUp
put id of this card into origCard
ask "find"
put it into theFind
ask "replace" && theFind && "with"
put it into theReplace
put 0 into x
repeat
set cursor to busy
find international theFind
if the result is not "" then
answer theFind && "not found" with "OK"
exit mouseUp
end if
answer "substitute" && theReplace && "for" && value(the foundChunk) with "no" or "yes"
if it is "yes" then
put theReplace into the foundChunk
add 1 to x
end if
end repeat
go origCard
answer "total substitutions=" & x with "OK"
end mouseUp

Field script to search/replace in which the first character in each line of the field is to be substituted for the third. (Space between them is "char 2" e.g. ). Example of such a list: kyukanji.html. Set the field to "Don't Search". Hold the command key down while clicking the field to start the script.

on mouseUp
put id of this card into thisCard
put the number of lines in me into totalNo
repeat with x=1 to totalNo
lock screen
set cursor to 3
get char 1 of line x of me
if it is empty then
exit repeat
else
put it into theFind
end if
get char 3 of line x of me
if it is empty then
exit repeat
else
put it into theReplace
end if
put 0 into y
repeat
put "Replacing" && theFind && "with" && theReplace
set cursor to busy
find international theFind
if the result is not "" then
exit repeat
else
put theReplace into the foundChunk
end if
add 1 to y
end repeat
unlock screen
go thisCard
put theFind && theReplace && y && "total left:" && (totalNo - x)
wait 15 sec
end repeat
put "finished all" && totalNo
end if

go to Watson index (English) (Japanese) | J studies
Michael Watson, Faculty of International Studies, Meiji Gakuin University
comments to: watson[at]k.meijigakuin.ac.jp
this page added 96/12/10
this site: http:///www.meijigakuin.ac.jp/~watson