First time here? Check out the FAQ!
x

How do I collect variables?

0 votes
454 views
When using hotValues I can collect using "(1 to: 9) collect: [ :i | !fader suffix: i]".

But how can I do that with variables either in a smalltalk script or in a tool? There's also the way to use "('fader' suffix: i) asHotValue" so I can use Strings but there's no "asVariable" message.

In short: how can I collect the variables x1, x2 and x3?

Thanks!
asked Nov 17, 2015 in Capytalk & Smalltalk by kymaguy (Virtuoso) (10,580 points)

I tried this experiment

| var |

var := 'name'.

var := (1 to: 10) collect: [:i | '?'&var&i ].

(inputs at: 1) start: 0 s freq: (var at: 1)
 

... but yes I see what the problem is. We need a way to cast that String as a green variable but there doesn't seem to  be any documented way of doing that.

Are you trying to create green variables with numbers at the ends?  How do you want to use the variables?  Maybe there is another way to accomplish this.
no, actually I want to refer to variables in a tool. the variables (x1-x99) are linked to hotValues. right now I do:
xArray := OrderedCollection new.
xArray add: x1.
xArray add: x2.
xArray add: x3. etc.
Is there a better way to do this?
Sorry, but the way you are doing it now is the best way to do it.
I see.. At least now I know it's worth the typing :)

Please log in or register to answer this question.

...