First time here? Check out the FAQ!
x

How can I see the messages I can send to a SmallTalk object?

0 votes
642 views
I'm trying to construct a SoundCollection in a script and I'm trying to guess what message to pass to it to add a Sound to my collection. Is there any way of exploring what messages a SmallTalk object can accept?
asked Jul 8, 2018 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (15,840 points)

2 Answers

+1 vote

Is it an OrderedCollection? If so, then you could use add:, addLast:, or addFirst:.

If it is an Array, you can put a Sound into the Array at an index using at:put:.

You could check in the Smalltalk appendix at the end of Kyma X Revealed for more...

answered Jul 9, 2018 by ssc (Savant) (128,120 points)
I was constructing this group of Sounds in order to set them as the input to a Sound that takes multiple Sounds in its input field. In other words to replace the placeholder SoundCollectionVariable. What kind of object can I use to replace the SoundCollectionVariable in my flow? I tried using an array but get an error.

If I use collect:, what ever that creates seems to work. Doesn't collect: just create an array though?
HI Alan, An Array ought to work. How are you creating it (could you paste the code here) and where is it (e.g. a Script? a Dialog?) Thanks!
Way! Thanks, telling me Arrays should work made me look at it again and find what I was doing wrong... I'll post what I did as an answer then I can format it better...
.. other than the SmallTalk appendix is there any way of finding out what messages an object can take? For instance SoundCollection isn't mentioned in the appendix.

(re-reading the appendix more carefully I've just discovered the "self debug:..." message. Now that's going to be useful for debugging scripts!)
SoundCollection isn't in the Appendix because it's not a Smalltalk class (but anyway, you already figured that out in your examples below where you use Arrays and OrderedCollections).  :)
0 votes

Yes, you can set a Sound's input to an Arrays of sounds (if it's one of those Sounds that can handle multiple Sounds in its input field).

This isn't the most elegant way, but just to show it's possible here's code that uses an Array of Sounds:

| sounds sound files|

files := ('balloon-clicky.aiff' sampleFileNamesInSameFolder).
sounds := Array new: (files size).

(1 to: (files size)) do: [:i|
    sound := scrubber samplefile: (files at: i).
    sounds at: i put: sound.].

selector start: 0 selectorInputs: sounds.

 

What I was doing wrong before was I was trying to use the "add:" message with the Array and not setting its size on creation, instead of using "at: ... put:".

A more elegant way of doing this is to use "add:" with an OrderedCollection:

 

| soundCollection sound|

soundCollection := OrderedCollection new.

('balloon-clicky.aiff' sampleFileNamesInSameFolder) do: [:file|
    sound := scrubber samplefile: file.
    soundCollection add: sound.].

selector start: 0 selectorInputs: soundCollection.

 

And the most elegant way, in this instance, is to use "collect:"

 

selector start: 0 selectorInputs: ((
    'balloon-clicky.aiff' sampleFileNamesInSameFolder) collect: [:file|
    scrubber samplefile: file]).

 

 

answered Jul 13, 2018 by alan-jackson (Virtuoso) (15,840 points)
...