parents ScriptEditor and Smile
parents ScriptEditor and Smile
- Subject: parents ScriptEditor and Smile
- From: "Patrick S. Page-McCaw" <email@hidden>
- Date: Wed, 14 Feb 2001 18:03:47 -0800
Suddenly, all that recent esoteric talk about parents and inheritance is
beginning to look a lot more interesting, ok maybe not interesting but
relevant. I'm having what I think is a problem understanding inheritance.
There have been lots of posts on this subject recently, but I'm not sure I
get it yet. And I really need to get away from the computer and back to my
test tubes. (I'm a pointy-headed molecular geneticist, not a
propeller-headed programmer ;-) )
I am trying to use Serial Port OSAX and Dialog Director to create an
application that will move a microscope stage to one of 96 positions.
Works great (in pieces), many thanks to SMILE, DD and Serial Port! Except
that the scripts are very large. ( Reasons that the script is large, skip
if you dont care: To initiate the stage I need to send about 5k of text
over the serial port. This could be in a separate file but then the
likelihood of losing the file and the app breaking would be really high.
Also the Dialog Director dialog definitions take up alot of space (my
dialog has 96 radio buttons, then miscellaneous others). Oh, because I can
never remember my variable names, the names are very descriptive (long).
So there I am at the 32k limit and I really dont want to change names like
serialPortOpenFlag to x. )
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.
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?
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
Many thanks,
Patrick