Re: A question
Alexey Zinger <inline_four-/[email protected]> Mon, 17 Sep 2012 06:50:29 -0700 (PDT)
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <[email protected]> |
I have a feeling, this should work:
interpreter.set("a", interpreter.get("a" + i));
But why are you doing it like that?=A0 Wouldn't it be easier to manipulate =
a collection or array of of these labels rather than hand-manipulating inte=
rpreter's namespace?
=A0
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 th=
is.
I have these visual elements:
Label a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
I have an array of words:
String[] words =3D 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=3D0;i<=3Dmaxwords;i++) {
=A0=A0=A0 Interpreter interpreter =3D new Interpreter();
=A0=A0=A0 try {
=A0=A0=A0 =A0=A0=A0 interpreter.set("tmp",words[i]);
=A0=A0=A0 =A0=A0=A0 interpreter.set("a","a"+String.valueOf(i));
=A0=A0=A0 =A0=A0=A0 interpreter.eval("a.setText(tmp)");
=A0=A0=A0 } catch (EvalError e2) {
=A0=A0=A0 =A0=A0=A0 e2.printStackTrace();
=A0=A0=A0 }
}
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 agai=
n?
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/