[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

TkVariable Array?

Kujawa, Greg

11/18/2004 3:14:00 PM

I am attempting to create an array of TkScale widgets to be used for scoring
a survey. This is because there might not always be a fixed number of
scoring responses and I wanted my script to be flexible. The values of the
TkScale widgets need to be stored for future reference. Therefore I assumed
the need to associate them with TkVariable objects. Here's my code:

# Create a scale widget for scoring each category
@@scales=Array.new
@@scores=TkVariable.new.to_a
@@category.each_index { |i|
@@scales[i]=
TkScale.new(@@survey) {
from 0
to 9
length 400
orient 'horizontal'
tickinterval 1
variable @@scores[i]
}
}

The problem is when I try to return the values of the TkVariable array
(@@scores) all I get back is an empty pair of brackets. Any suggestions
about how I could fix this would be appreciated. I'm only about two weeks
into learning the Ruby language and don't know a lot of Tk, as I am just
googling for sample code to try to guess at this point.

Thanks!


2 Answers

Matt Maycock

11/18/2004 6:56:00 PM

0

Maybe what you want is:
@@scores = @@category.map {TkVariable.new}

which is an array OF tkvariables. You were trying to look at a
TkVariable as an array (which doesn't really make sense).

May the force be with you.

~Me!

--
There's no word in the English language for what you do to a dead
thing to make it stop chasing you.


Hidetoshi NAGAI

11/19/2004 7:10:00 AM

0