From: Josh Cheek Date: 2010-10-09T10:18:46+09:00 Subject: Re: urgent help required#wrote: > prompts5 = ["Span type"] > defaults5 = ["1. Simply supported"] > @t_slab = ["1. Simply supported |2. Interior span |3. End span |4. > Cantilever"] > list5 = [@t_slab] > title5="Please select the type of the span" > @input_tslab = inputbox prompts5, defaults5, list5,title5 > > kay_array = [1.0, 1.5, 1.3, 0.4] > @ka = kay_array[(@input_tslab).to_i-1] > > > If "3. End span" is selected by in the UI, following error is > displayed.. > > Error: # "]:Array> > -- > Posted via http://www.ruby-forum.com/. > > I assume you are using Google sketchup, and you are invoking this method http://code.google.com/apis/sketchup/docs/ourdoc/ui.html#inputbox If so, you can see they say that it returns nil or an Array, so @input_tslab would be an Array. Then, you call (@input_tslab).to_i, first of all, you do not need parentheses, they don't do anything. Second, that means you are invoking the to_i method on the array that @input_tslab has received from the inputbox method. But to_i is not a method that Arrays have ( http://ruby-doc.org/core/classes/Array.html). You need to figure out explicitly what will be returned (ie what does this Array actually contain? I know nothing about sketchup, so can only guess that it is the text contents of the inputbox -- if it even has a textbox.) And then you need to figure out what you want to do with it. In this case, it looks like you want to associate it with a number. Figure out how to get from what is returned to the desired number. In your particular example, it looks like saying @input_tslav.first.to_i will work, but this might be a shaky solution, I'd expect if you get more familiar with the API this will be easier for you. Also, make sure to handle the situation where the user cancels the box, and nil is returned. --001485f7c3fc7ad135049224e8b6--