Re: script object scoping
Re: script object scoping
- Subject: Re: script object scoping
- From: Axel Luttgens <email@hidden>
- Date: Sun, 4 Jul 2010 10:57:07 +0200
Le 3 juil. 2010 à 22:03:42, tom wible a écrit :
> i've successfully implemented hiroto's cascading constructors, then applied that to another script.app:
>
> {code}
> property tvpi2crontabP : "/DVR/scripts/tvpi2crontab.app"
> property tvpi2crontab : (load script POSIX file tvpi2crontabP)
>
> on getLastPlayed(fileName)
> ...
> end
>
> on newRecClass(fileName)
> script recClass
> property parent : tvpi2crontab's newTvpiProgram(fileName)
> property fileSize : 0.0
> property lastPlayPos : missing value
> property lastPlayDate : missing value
> ...
> to setFileInfo(fileName, fileSize, fileDate)
> copy fileName to my fileName
> copy fileSize to my fileSize
> set my startEvent to tvpi2crontab's newTvpiEvent()
> copy fileDate to my startEvent's datetime
> set {my lastPlayPos, my lastPlayDate} to getLastPlayed(fileName)
> end setFileInfo
> ...
> end
>
> on newTvpiClass(fileName)
> script tvpiClass
> property parent : newRecClass(fileName)
>
> to setFileInfo(fileName, fileSize, fileDate)
> continue setFileInfo(fileName, fileSize, fileDate)
> ...
> {code}
> but i get the following error on run:
>
> "«script tvpiClass» doesn't understand the getLastPlayed message."
>
> now what? it was happy to set my startEvent to tvpi2crontab's newTvpiEvent(), so the app's top-level is visible to instances of a script object...
Hello Tom,
Without the full code, it's difficult to get a precise idea of the overall organization, so I'll do some guessing... ;-)
Aren't you just facing the following:
on doIt()
end doIt
on newA()
script A
property parent : application "Finder"
end script
end newA
on newB()
script B
property parent : newA()
end script
end newB
set S to newB()
S's doIt()
--> Error in Finder: «script B» doesn't understand the doIt message."
If yes, this could mean that the object model may need to be somewhat reviewed.
For example, if the doIt() method logically appears to belong to A:
on newA()
script A
property parent : application "Finder"
on doIt()
end doIt
end script
end newA
on newB()
script B
property parent : newA()
end script
end newB
set S to newB()
S's doIt()
On the other hand, it could well be that the doIt() method is best viewed as belonging to a class representative of objects of their own, B being in charge to manage such objects:
on newA()
script A
property parent : application "Finder"
end script
end newA
on newB()
script B
property parent : newA()
on doIt(O)
O's doIt()
end doIt
end script
end newB
on newC()
script
on doIt()
end doIt
end script
end newC
set S to newB()
set T to newC()
S's doIt(T)
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden