Script Objects, Inheritance and Delegation
Script Objects, Inheritance and Delegation
- Subject: Script Objects, Inheritance and Delegation
- From: David Weiss <email@hidden>
- Date: Tue, 13 Apr 2004 17:24:57 -0700
If I wanted to write an automated test system with AppleScript I would
use the following template for each of my test scripts:
property parent : application "eXodus"
property name : "Some nice test name"
property target : {"Microsoft Word", "Microsoft Entourage", "Microsoft
Excel", "Microsoft PowerPoint", "MSN Messenger", "Virtual PC"}
property testCaseID : 20324
on run
startAutomation for me
with timeout of my standardTimeout seconds
try
if preTest() then mainTest()
postTest()
on error errorMessage number errorNumber
logTestError(errorMessage, errorNumber)
end try
end timeout
set theScriptResult to scriptResult()
quit
return theScriptResult
end run
on mainTest()
-- your test code goes here
tell my XLib to LogComment("test")
end mainTest
---
This could be very useful. This script template would inherit from the
AppleScript application named eXodus. Special cases could override the
standard preTest() and postTest() if needed and continue to delegate
the standard functionality. The function "startAutomation for me" would
load 40 or so different script objects into properties in the eXodus
application. The libraries could have access to the script's target
information.
Questions:
1. Why can't I call a function in one of the loaded libraries like
this: XLib's LogComment("My comment text") I know tell my XLib to
LogComment("test") works, but why can't I use the possessive form?
2. In any of the loaded libraries, (that also inherit from the eXodus
application) I can't call any of the other functions. For example, if I
loaded a library named "XLib" and in it were two functions like so:
on LogPass(passText)
say "LogPass"
writeToFile(passText)
end LogPass
and
on writeToFile(theText)
display dialog theText
end writeToFile
I will hear "LogPass" but I'll get an error when I try to call
writeToFile() In order to call another function in the same script
object I must us this syntax:
tell my parent's XLib to writeToFile(theText)
and when accessing "my own script object" properties I must us this
syntax:
my parent's Xlib's standardTimeout
3. In the eXodus applescript I define a property named target which is
missing value. The script overrides this property and defines it with a
list. Yet when I try to access the target property from the eXodus
application script I get only missing value! This is why
startAutomation has a parameter "me" which allows me to set these
properties for use by the other libraries. Since the script is over
ridding the properties, why aren't they overridden?
Why oh why? This inheritance stuff looked sooo useful, but then I seem
to loose all the script object goodness when I inherit! Does anyone
know why this is?
David Weiss
P.S. I've poured over Chapter 9 of the AppleScript Language Guide long
enough.
_______________________________________________
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.