Hi all,
and thanks in advance for those of you who have the patience to answer my newbie question. I am experimenting with external script objects and have copied the following code from a book (AS in a Nutshell):
script Collection
property col : {}
on getCol()
return col
end getCol
on setCol(rec)
if (class of rec is record) then
set col to rec
else
return
end if
end setCol
on add(mem)
if (class of mem is record) then
set col to col & mem
else
return
end if
end add
on getMem(mem)
return mem
end getMem
end script
–set ObjCol to (load script “MacOS9:desktop folder:Collection”)
set ObjCol to Collection
tell ObjCol to setCol({Earth:“12756”, Mercury:“4880”})
tell ObjCol to add({Venus:“12104”})
tell ObjCol to getCol()
set myCol to the result
tell ObjCol to getMem(Earth of myCol)
set retValue to the result
set msg to “Earth is " & retValue & " kilometers in diameter”
display dialog msg
This works fine. BUT: When I cut the script part and save it to a script object (for brevity’s sake on the desktop) it won’t work anymore. The script seems to be loaded alright (that’s what the EventWindow says), but the methods are not recognized.
Can someone see where I am going wrong? Thanks again,
Dirk