You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Kyle McAbee <k....@treev.com> on 2005/02/05 00:09:52 UTC
Can variables be declared in BeanShell function?
Dear JMeter Users:
Does anyone know whether BeanShell (current bsh-2.0b2.jar file) hosted by JMeter 2.0.2 will allow a script to declare variables? The following BeanShell function fails.
${__BeanShell(String str1; String str2; str1 = "abc"; str2 = "def"; str1 = str1 + str2; return str1.toString(); ) }
The same code put in a function in NetBeans 3.6 succeeds:
private static String showConcatenation () {
String str1;
String str2;
str1 = "abc";
str2 = "def";
str1 = str1 + str2;
return str1.toString();
}
public static void main(String[] args) {
System.out.println(KillMeNow.showConcatenation());
}
Sincerely yours,
Kyle
Re: Can variables be declared in BeanShell function?
Posted by sebb <se...@gmail.com>.
On Fri, 4 Feb 2005 18:09:52 -0500, Kyle McAbee <k....@treev.com> wrote:
> Dear JMeter Users:
>
> Does anyone know whether BeanShell (current bsh-2.0b2.jar file) hosted by JMeter 2.0.2 will allow a script to declare variables? The following BeanShell function fails.
What do you mean by "fails"?
Are there any error messages in jmeter.log or the console?
I think BeanShell allows variables to be used without predeclaring
them - have you tried that?
By the way, the toString() method call is redundant - str1 is already a string.
>
> ${__BeanShell(String str1; String str2; str1 = "abc"; str2 = "def"; str1 = str1 + str2; return str1.toString(); ) }
>
> The same code put in a function in NetBeans 3.6 succeeds:
>
> private static String showConcatenation () {
>
> String str1;
> String str2;
>
> str1 = "abc";
> str2 = "def";
> str1 = str1 + str2;
>
> return str1.toString();
> }
>
> public static void main(String[] args) {
> System.out.println(KillMeNow.showConcatenation());
> }
>
> Sincerely yours,
>
> Kyle
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org