Re: Search and Replace Scripts

Boyd Sweeney (starnet!apple!puzzler.nichols.com!sweeneyb)
Fri, 11 Feb 1994 08:51:42 -0500

>Is there a convenient way to search all of the cards in a stack and
>replace the current scripts with the same change? For example, I want to
>do additional checking after a button has been depressed. I know what I
>want to add, but is there a way to add the changes in one fell swoop
>instead of having to edit each script?
>
>Example:
>
>Current = if audio is True then
> play "file1.au"
> end if
>
>Desired = if audio is True then
> if there is a file "file1.au" then
> play "file1.au"
> else
> show field "File Error Text"
> wait errorDelay ticks
> hide field "File Error Text"
> end if
> end if
>
>How can I make this change on all cards when the file (ie: file1, file2,
>file3, etc.) is unique to each card?
>
>Also, if I clone a stack, can I replace all of the references in that
>stack to reference the new stack name?
>
Sounds to me like you'd have to write a custom script to handle the
first task. You'd scan the scripts for the proper text, save the file
name to a variable, delete the old text, and use the variable when
inserting the new text. It's probably more trouble than it's worth!
You'd spend more time writing the conversion script than doing the
changes manually.
I can probably help with the second problem. I have a stack that
allows you to do "global" search and replace operations for multiple
object scripts. It should also help you find those instances where
you need to make changes to your "if" constructs. I'll uuencode the
stack and mail it to you directly.
If anyone else is interested in this stack, I'll try to find the
time to clean it up a bit next week, and send it to the MetaCard folks.
Scott could probably put it out in the contrib directory.
By the way. Do you know of any sites on the net where I might find
a good collection of sound files?

***************************************************************
* Boyd Sweeney Scientist, Nichols Research Corporation *
* sweeneyb@puzzler.nichols.com (205) 883-1170x1775 *
***************************************************************