• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Parents/Child Scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parents/Child Scripts


  • Subject: Re: Parents/Child Scripts
  • From: Paul Skinner <email@hidden>
  • Date: Sat, 11 May 2002 11:56:31 -0400

On Friday, May 10, 2002, at 10:32 PM, Lachlan Deck wrote:

Hi there,
From: "Steve Suranie" <email@hidden>
Hi folks
Can anyone send me a short example of how to pass a variable between a parent and child script.
(a peek inside parent script)
...
set theText to "Pass me please!"
try
set childScript to (load script <path to script> as alias)
tell childScript
receiveText(theText)
end tell
on error
display dialog "No such script."
end try
...
(inside child script)
...
on receiveText(someText)
display dialog ("I got something: " & return & tab & someText)
end receiveText
Thanks
Steve

with regards,
--
Lachlan Deck

While this works, it demonstrates loading a script into another script, it isn't creating a child-parent relationship.
A child script can declare a parent.

property parent:parentObjectOfSomeSort

But no script can declare a child. This follows a buddhist philosophy. You pick your parent. They don't pick you.

This same thing done with the parent property would go like...

--'child' script
property parent : (load script "Dalai:Users:paulskin:Desktop:parent as alias)
set theText to "Pass me please!"
my receiveText(theText)
-->I got something:Pass me please!

--'parent' script
on receiveText(someText)
display dialog ("I got something: " & someText)
end receiveText

On Saturday, May 11, 2002, at 12:34 AM, Michael Kelly wrote:

On 5/10/02 3:03 PM, has <email@hidden> wrote:

Steve Suranie wrote:

Can anyone send me a short example of how to pass a variable between a parent and child script.
Not sure what you mean here: "parent" and "child" are terms used in object oriented programming - specifically in discussions about inheritance.
Maybe I'm way off-base here, but isn't the OP talking about parent and child _scripts_? I.e., spawned processes. For instance, the httpd daemon spawns a new process for each connection, I believe. Therefore, it is the parent, and the processes it spawns are the children. Am I correct, or have I been hallucinating? Unfortunately I have real idea of how to do this, let alone in AS. I'm mostly trying to make sure that I'm not gravely misunderstanding something.

You are off-base. Tag!

Parent is a property of every script. It can be declared or not. If undeclared, a script's default parent is <<script applescript>> ie. Applescript itself. If declared then a script's parent is the declared object.

ASLG p.331
The script object listed in a Parent property definition is called the parent script object, or parent. A script object that includes a Parent property is referred to as a child script object, or child. The Parent property is not required. A script object can have many children, but a child script object can have only one parent.

--Example 1
my parent
--> <<script applescript>> ie.AppleScript.
--End Example 1


--Example 2
property parent : application "Finder"
my parent
-->application "Finder"
--End Example 2


--Example 3
property parent : application "Finder"
my parent
-->application "Finder"
naturalChild's parent
--> <<script>> ie.This script.

script naturalChild
end script
--End Example 3


--Example 4
property parent : application "Finder"
my parent
-->application "Finder"
my naturalChild's parent
--> <<script>> ie.This script.
my naturalChild's baby's parent
--> <<script>> ie.This script.
--Just like real life. The grandparent's think it's their baby.

script naturalChild
script baby
end script
end script
--End Example 4

Maybe I'm way off-base here, but isn't the OP talking about parent and child_scripts_? I.e., spawned processes.
While scripts can generate, store and run scripts I don't think that's what you were talking about. I guess 'Spawned processes' in AppleScript would be those scripts created and run by 'run script'. Now whose baby is that?
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Parents/Child Scripts
      • From: Michael Kelly <email@hidden>
References: 
 >Parents/Child Scripts (From: Lachlan Deck <email@hidden>)

  • Prev by Date: Re: setting rows and columns of applework spreadsheet
  • Next by Date: Scripting menu commands?
  • Previous by thread: Parents/Child Scripts
  • Next by thread: Re: Parents/Child Scripts
  • Index(es):
    • Date
    • Thread