Does anyone know of one?
Offline
Baderous wrote:
You'll have to use reflection. Inspect the Behavior class.
Hmm, I looked, and I didn't see much. Plus, I just want to bump this so it gets answered.

Offline
"accessing method dictionary" is a clear name that points out where you have to search. After looking at that protocol's methods you find 2 of your interest: #sourceCodeAt: and #sourceMethodAt:. Choose the one that fits you better. To test, open an Inspector window on some morph, for intance a sprite, and then type:
self class sourceCodeAt: #attributeNames
Here I chose the #attributeNames method, but you can choose any other one.
Offline
Baderous wrote:
"accessing method dictionary" is a clear name that points out where you have to search. After looking at that protocol's methods you find 2 of your interest: #sourceCodeAt: and #sourceMethodAt:. Choose the one that fits you better. To test, open an Inspector window on some morph, for intance a sprite, and then type:
Code:
self class sourceCodeAt: #attributeNamesHere I chose the #attributeNames method, but you can choose any other one.
Hmmm. Nice find, Baderous. Maybe I'm doing something wrong though, but it only seems to work on instance methods. For example, what you posted works, but on a sprite, the following code returns the error "key not found":
self class sourceCodeAt: #blockSpecs
Maybe I'm making some silly mistake though. So you have any idea why it won't work?

Offline
Greenatic wrote:
Baderous wrote:
"accessing method dictionary" is a clear name that points out where you have to search. After looking at that protocol's methods you find 2 of your interest: #sourceCodeAt: and #sourceMethodAt:. Choose the one that fits you better. To test, open an Inspector window on some morph, for intance a sprite, and then type:
Code:
self class sourceCodeAt: #attributeNamesHere I chose the #attributeNames method, but you can choose any other one.
Hmmm. Nice find, Baderous. Maybe I'm doing something wrong though, but it only seems to work on instance methods. For example, what you posted works, but on a sprite, the following code returns the error "key not found":
Code:
self class sourceCodeAt: #blockSpecsMaybe I'm making some silly mistake though. So you have any idea why it won't work?
Try with a colon at the end.
Offline
Greenatic wrote:
Baderous wrote:
"accessing method dictionary" is a clear name that points out where you have to search. After looking at that protocol's methods you find 2 of your interest: #sourceCodeAt: and #sourceMethodAt:. Choose the one that fits you better. To test, open an Inspector window on some morph, for intance a sprite, and then type:
Code:
self class sourceCodeAt: #attributeNamesHere I chose the #attributeNames method, but you can choose any other one.
Hmmm. Nice find, Baderous. Maybe I'm doing something wrong though, but it only seems to work on instance methods. For example, what you posted works, but on a sprite, the following code returns the error "key not found":
Code:
self class sourceCodeAt: #blockSpecsMaybe I'm making some silly mistake though. So you have any idea why it won't work?
Doing "self class" on a sprite returns the name of its class, ScratchSpriteMorph. So, calling those 2 methods on it will only work for instance methods. To access its class methods you have to call those methods on the class's class, which is "ScratchSpriteMorph class". So all you have to do is:
self class class sourceCodeAt: #blockSpecs
Offline
Baderous wrote:
Greenatic wrote:
Baderous wrote:
"accessing method dictionary" is a clear name that points out where you have to search. After looking at that protocol's methods you find 2 of your interest: #sourceCodeAt: and #sourceMethodAt:. Choose the one that fits you better. To test, open an Inspector window on some morph, for intance a sprite, and then type:
Code:
self class sourceCodeAt: #attributeNamesHere I chose the #attributeNames method, but you can choose any other one.
Hmmm. Nice find, Baderous. Maybe I'm doing something wrong though, but it only seems to work on instance methods. For example, what you posted works, but on a sprite, the following code returns the error "key not found":
Code:
self class sourceCodeAt: #blockSpecsMaybe I'm making some silly mistake though. So you have any idea why it won't work?
Doing "self class" on a sprite returns the name of its class, ScratchSpriteMorph. So, calling those 2 methods on it will only work for instance methods. To access its class methods you have to call those methods on the class's class, which is "ScratchSpriteMorph class". So all you have to do is:
Code:
self class class sourceCodeAt: #blockSpecs
That works perfectly! I think that's what scimonster needed...

Offline
Nice find!
Offline
Yay! I found a way to have the blocks get in, but this looks like it should be useful for the uncoloredArgMorphFor:.
Offline