Re: parents ScriptEditor and Smile
Re: parents ScriptEditor and Smile
- Subject: Re: parents ScriptEditor and Smile
- From: email@hidden
- Date: Thu, 15 Feb 2001 03:36:41 EST
In a message dated 2/14/01 9:49:52 PM, Patrick S. Page-McCaw wrote:
<snip introductory/background info>
>
I broke the script down into three separate scripts, two handler libraries
>
(if I am using the term correctly) and the main user interface scipt. The
>
main script calls from the library script like this:
>
>
property parent: load script file "disk:folder:serial library"
>
>
The library has its own parent called the same way. If I compile in Script
>
Editor it works fine except that I have to delete a fair bit or the size
>
goes over 32k (I think) and Script Editor goes bang. Bang means quits w/no
>
warning or quits w/ a type 3 error. Sometimes really bang and I have to
>
restart. I'm using a PowerBook with OS9.1.
>
>
Smile compiles fine, but it cant run. It balks at the first handler in the
>
grandparent. "script does not understand the handler", is more or less the
>
error message.
>
>
I'll save you reading through the actual scripts. These shorter scripts
>
reproduce the effect. (They were written on a G4 500MHz, OS9.0.4. so this
>
does not seem to be a machine specific phenomena) They work when saved as
>
"classic applets" in Script Editor, but dont work in SMILE when saved as
>
"Application" or "Smile doc"
>
>
---first file: saved as "Mom"
>
property depth : 2
>
>
on AskMom()
>
display dialog "do your homework, dear"
>
end AskMom
>
>
---second file: saved as "Dad"
>
property depth : 1
>
property parent : load script file "Disk:Desktop Folder:Parents:Mom"
>
>
my AskMom()
>
>
to askDad()
>
display dialog "I dunno, ask your mother " & depth
>
end askDad
>
>
---third file: saved as "child"
>
property parent : load script file "Disk:Desktop Folder:Parents:Dad"
>
>
my askDad()
>
my AskMom()
>
>
clicking run button in smile script window of Dad and child works to one
>
level "up" in the heirarchy (or is that down). Ie, running Dad gives a 'do
>
your homework' dialog, clicking run in "child" gives the 'I dunno' dialog
>
followed by 'script does not understand'. Double clicking either gives the
>
'script does not understand' error.
>
>
When saved in Script Editor the scripts behave as I would expect. Of
>
course I might be expecting the wrong thing: here's what it does "child"
>
gives the 'I dunno' then the 'do your homework' dialogs. When the Script
>
Editor version of "child" uses as a parent the SMILE versions of Mom and
>
Dad it can not call the handlers.
>
>
So, is there something about SMILE that has changed the behavior of load
>
script or inheritance ? or am I misunderstanding something fundamental?
>
The SMILE help suggests new ways of inheritance through windows? but I just
>
couldnt understand.
Apparently there is something about Smile. I got the same behavior which
seems to be wrong behavior. I'm sure Emmanual is looking into it right now.
>
A second issue: Also covered before but I cant find the relevant posts. I
>
save my 'wonder' script as an application then move it to a different
>
machine and it seems to be broken with the 'script does not understand
>
error'. This time with even more double chevrons. I thought the app saved
>
version would have the relevant code compiled into it, so the OSAX etc does
>
not have to be on the new computer. Am I mistaken?
The parent property and other libraries are included in the applet at compile
time, but osax are not (pity). The osax will need to be on the machine
running the applet
>
A third issue: I want the scripts to be accessible to the users (I never
>
ever want to see them again, the scripts not the users) so I want the
>
scripts to be more easily compiled in the future. Is there an _easy_ way
>
of writing the 'load script file ... ' so that it is more transparent and
>
robust. Something like load script myPath:serial library. so that as long
>
as the library file name does not change and all the files are in the same
>
folder then the child can find the parent. I have a feeling this too was
>
also covered recently... I will pay more attention in class ... I will
>
pay more attention in class... or figure out how to search the unsearchable
>
archives
Here is a battle tested snippet which does this. It creates a script object
<cartHandler> which contains about 50 handlers, rather than using the parent
property (which I have decided is of limited utility because of certain scope
issues).
property cartHandler : "empty"
-- modified June 29, 2000 to look for cart.hndl only in the same folder as
this acgi
-- modified July 22, 2000 to use the more elegant ":" as alias (credit
Motoyuki Tanaka)
on run
if cartHandler is equal to "empty" then
try
set basePath to (":" as alias) as string
set cartHandlerSrc to (basePath & "cart.hndl") as string
set cartHandler to load script file (cartHandlerSrc)
on error
set cartHandler to "empty"
tell me to quit
end try
end if
set lastused to 0
end run
Note that you cannot make a script portable *and* editable by setting a
property to a loaded script object.
property parent: load script file "hd:filename"
--> fails on different machine due to different path
property parent: load script file ((":" as alias) as string & "filename")
--> fails on different machine because ":" as alias evaulates to the path
to the Script Editor application, not the applet.
However, once run, the above method causes the library to be retained in the
property, saving launch time on subsequent runs.
Jeff Baumann
email@hidden
www.linkedresources.com