jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kannan, Sengamalam" <Sengamalam.Kan...@AIG.COM>
Subject RE: Variable substitution in BeanShell Post Processor
Date Tue, 31 Mar 2009 09:59:32 GMT
Thanks Sebb for your quick reply.

Without using eval function if I try

 if (begin.equals(vars.get("DateVal_"+p)))

vars.get("LeaveNum_"+i);

is not working as its taking "LeaveNum_" & "DateVal_" as a variable which doesn't exists.

I cannot use foreach controller for this as I have to compare the Regular Expression values
(DateVal_1,2,etc) with a value in CSV Data config file and based on the comparison assign
a value to a variable and pass  the same to the next HTTP request.

Please help!


Thanks & Regards
Sengamalam Kannan
Testing CoE
Mobile: +91 99529 67005
Tel: +91 44 6615 2684

-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com]
Sent: Tuesday, March 31, 2009 3:23 PM
To: JMeter Users List
Subject: Re: Variable substitution in BeanShell Post Processor

On 31/03/2009, Kannan, Sengamalam <Sengamalam.Kannan@aig.com> wrote:
> Regular Expression Variable names are DateVal_1, DateVal_2, etc. In a for-loop within
Beanshell post processor, I want to use these variables using variable substitution like DateVal_i
if i is counter variable.
>
>  Problem:
>  Tried the following code but didn't work.
>
>  daten = vars.get("DateVal_matchNr");
>  begindt=vars.get("begin")
>  i=0;
>  for (int p = 0; p <= daten; p++)
>  {
>    if (begin.equals(eval("DateVal_"+p)))
>    {
>
>      leave = vars.get(eval("LeaveNum_"+i));
>      vars.put("leavenumber", leave);
>     }
>    i++;
>  }
>
>  I don't know how to use eval function within vars.get and retrieve the value of the
variable.

There is no JMeter eval function in BeanShell.

To retrieve the value of a variable in BeanShell, use

get(<String name of variable>)

This is what you have done for daten and begindt.
Just do the same for variable names that you need to construct -
create a string containing the full variable name, e.g. using
concatenation.

Just remove the eval method calls.

>  Please help!
>
>
>  Thanks & Regards
>
> Sengamalam Kannan
>  Testing CoE
>  Mobile: +91 99529 67005
>  Tel: +91 44 6615 2684
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message