[comp.sys.mac.hypercard] Scripting from scripts

aleskine@cs.hut.fi (Arto Leskinen) (06/20/91)

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
aleskine@saha.hut.fi
arto leskinen

burchil@ccu.umanitoba.ca (Charles Andrew Burchill) (06/20/91)

In <ALESKINE.91Jun19191747@saavi.hut.fi> 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
>aleskine@saha.hut.fi
  The simple answer is yes you can added information to the stack script.
The method that you used will erase all of the information in the stack
script though.  Remeber you have to include function, or handler headings.
If you want to keep information in the stack script try.
  Put ... after last char of stack script
or
  Put "..." after line ? of stack script
I have no idea what you are trying to do so that is all I can offer.
If you have more questions please wire me.
Charles.
>arto leskinen

bcarter@claven.idbsu.edu (Bruce Carter) (06/21/91)

In article <1991Jun19.201346.3477@ccu.umanitoba.ca> burchil@ccu.umanitoba.ca
(Charles Andrew Burchill) writes:
>In <ALESKINE.91Jun19191747@saavi.hut.fi> aleskine@cs.hut.fi (Arto Leskinen)
writes:
>
>>How can I write scripts in to stack script from within script. For example
>>...
>>Can I write something like Put "Goto stack "&it into Stack Script
>>aleskine@saha.hut.fi

>  The simple answer is yes you can added information to the stack script.
>...
>  Put ... after last char of stack script
>or
>  Put "..." after line ? of stack script

Not exactly.  You have to use the "set" command to change scripts.  The easiest
way to do this is to build your script in a variable, then set the script to
that variable.  Something like:

put "on openStack" & return & "beep" & return & "end openStack" into newScript
set the script of this stack to newScript

If you need to modify an existing script, put it into a variable, then mess
with it, then set it back.  Like:

put the script of this stack into oldScript
put allMyNewGarbage after oldScript
set the script of this stack to oldScript
                                     <->
Bruce Carter, Courseware Development Coordinator      bcarter@claven.idbsu.edu
Boise State University, Boise, ID  83725              duscarte@idbsu.bitnet
(This message contains personal opinions only)        (208)385-1250@phone

Henry.Halff@p911.f421.n109.z1.FidoNet.Org (Henry Halff) (06/21/91)

>>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
>>aleskine@saha.hut.fi
>  The simple answer is yes you can added information to the stack
>script.
>The method that you used will erase all of the information in the
>stack
>script though.  Remeber you have to include function, or handler
>headings.
>If you want to keep information in the stack script try.
>  Put ... after last char of stack script
>or
>  Put "..." after line ? of stack script
 
Close, but no ceegar. Scripts are object properties, not containers, so
you need to say
 
set script of this stack to whatever
 
or
 
set script of this stack to script of this stack & return & whatever

 * Origin: The Clone: Macintosh Things - 301-946-8677 (1:109/421.911)

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (06/21/91)

In article <ALESKINE.91Jun19191747@saavi.hut.fi> 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.                     |