Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!apple!jdevoto From: jdevoto@Apple.COM (Jeanne A. E. DeVoto) Newsgroups: comp.sys.mac.hypercard Subject: Re: Scripting from scripts Summary: use "set" Message-ID: <54222@apple.Apple.COM> Date: 21 Jun 91 08:34:24 GMT References: Distribution: comp.sys.mac.hypercard Organization: Apple Computer Inc., Cupertino, CA Lines: 40 In article aleskine@cs.hut.fi (Arto Leskinen) writes: >How can I write scripts in to stack script from within script. For example >I have something like this: > Ask "Where to go" > DoLink(it) >... >Can I write something like Put "Goto stack "&it into Stack Script Close. But the script of an object is a property, not a container, so you need to set the property to a value rather than putting text into it. For example: set the script of card button "Foo" to ~ "on mouseUp" & return ~ & "go card" && it & return ~ & "end mouseUp" (where the ~ character stands for option-return). To add to an existing script, you read the script into a variable, add the new text to that variable, then set the script to the changed variable: put the script of this stack into scratchScript put "on goThere" & return & "go card" && it & return ~ & "end goThere" after scratchScript set the script of this stack to scratchScript You can also use the offset command to do quite a few sophisticated things to existing scripts - searching and replacing, for instance. The trick is, again, to pull the script into a variable, make your changes to the variable, then set the script to the changed variable. -- ========= jeanne a. e. devoto ======================================== jdevoto@apple.com | You may not distribute this article under a jdevoto@well.sf.ca.us | compilation copyright without my permission. ______________________________________________________________________ Apple Computer and I are not authorized | CI$: 72411,165 to speak for each other. |