Re: A question

<[email protected]> Mon, 17 Sep 2012 17:14:14 +0300 (EEST)
Newsgroups gmane.comp.java.beanshell.user
Message-ID <[email protected]>
It did not help but you are right - it will be better to use an array of elements.

Thanks

Alexey Zinger <inline_four-/[email protected]> wrote:
>I have a feeling, this should work:interpreter.set("a", interpreter.get("a" + i));
>But why are you doing it like that?  Wouldn't it be easier to manipulate a collection or array of of these labels rather than hand-manipulating interpreter's namespace?
> Alexey
>
>
>From: "[email protected]" <[email protected]>
>To: beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org 
>Sent: Monday, September 17, 2012 9:06 AM
>Subject: [Beanshell-users] A question
>
>Hello,
>
>I am trying to use BeanShell for something that I don't know if it is ever possible...Plese tell me is there a way to do it or stop wasting time on this.
>
>I have these visual elements:
>
>Label a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
>
>I have an array of words:
>
>String[] words = result.split(" ");
>
>This code works fine: 
>
>a1.setText(words[0]);
>a2.setText(words[1]);
>a3.setText(words[2]);
>a4.setText(words[3]);
>a5.setText(words[4]);
>a6.setText(words[5]);
>a7.setText(words[6]);
>a8.setText(words[7]);
>a9.setText(words[8]);
>a10.setText(words[9]);
>
>But what if I have not 10 but 100 elements...So I try to use this:
>
>for (int i=0;i<=maxwords;i++) {
>    Interpreter interpreter = new Interpreter();
>    try {
>        interpreter.set("tmp",words[i]);
>        interpreter.set("a","a"+String.valueOf(i));
>        interpreter.eval("a.setText(tmp)");
>    } catch (EvalError e2) {
>        e2.printStackTrace();
>    }
>}
>
>The problem is with this command:
>
>interpreter.set("a","a"+String.valueOf(i));
>
>If I use this:
>
>interpreter.set("a",a1);
>
>Everything is OK but what is the point to call all elements one by one again?
>
>Best wishes
>
>Georgi Bonchev 
>
>------------------------------------------------------------------------------
>Live Security Virtual Conference
>Exclusive live event will cover all the ways today's security and 
>threat landscape has changed and how IT managers can respond. Discussions 
>will include endpoint security, mobile security and the latest in malware 
>threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>Beanshell-users mailing list
>Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/