You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by "McCune, Tim" <tm...@yahoo-inc.com> on 2006/10/04 09:54:49 UTC

Nested variables

I'm trying to use the following expression in JMeter:

 

${myId_${__JavaScript(Math.floor(Math.random() * ${myId_matchNr}) + 1,
randomId)}}

 

and JMeter is evaluating it to:

 

${) * ${myId_matchNr}) + 1, randomId)}}

 

It seems to be able to handle 1 nested variable, inside of the JavaScript
function, but not the 2nd?  For instance, if I just use:

 

${__JavaScript(Math.floor(Math.random() * ${myId_matchNr}) + 1, randomId)}

 

this evaluates fine.  If I just use:

 

${myId_2}

 

this evaluates fine.  I basically have a list of strings that were extracted
by the Regular Expression Extractor (and stored in "myId_n" variables), and
I want to select one of them at random.  Is there a better way to do this?
I would appreciate any suggestions.

 

Thanks.

 

--Tim


Re: Nested variables

Posted by sebb <se...@gmail.com>.
On 04/10/06, McCune, Tim <tm...@yahoo-inc.com> wrote:
> I'm trying to use the following expression in JMeter:
>
>
>
> ${myId_${__JavaScript(Math.floor(Math.random() * ${myId_matchNr}) + 1,
> randomId)}}
>
>
>
> and JMeter is evaluating it to:
>
>
>
> ${) * ${myId_matchNr}) + 1, randomId)}}
>
>
>
> It seems to be able to handle 1 nested variable, inside of the JavaScript
> function, but not the 2nd?  For instance, if I just use:

Nested variable names are not supported.

>
>
> ${__JavaScript(Math.floor(Math.random() * ${myId_matchNr}) + 1, randomId)}
>
>
>
> this evaluates fine.  If I just use:
>
>
>
> ${myId_2}
>
>
>
> this evaluates fine.  I basically have a list of strings that were extracted
> by the Regular Expression Extractor (and stored in "myId_n" variables), and
> I want to select one of them at random.  Is there a better way to do this?
> I would appreciate any suggestions.
>

Why not pick a match at random initially? i.e. set Match No. to 0.

Otherwise, you will need to do this with BeanShell, something like:

${__BeanShell(vars.get("myId_${random}"))}



>
> Thanks.
>
>
>
> --Tim
>
>
>

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