Re: Storing values in an Array
Yep. Sorry I wasn't being very clear there was I? So set up the user counter as I suggested, and then vars.put("token_${userCounter}", "${newToken}); Then you can iterate through the token array with a foreach loop! :-) If you need additional information you can make more arrays too. Just do: vars.put("username_${userCounter}", "${username}"); And so forth. But if you do this, you'll need to make a new counter and increment it in your foreach loop if you want to reference the various data elements you need: vars.put("username", vars.get("username_${newCounter})); vars.put("newCounter", Integer.toString(${newCounter} + 1)); If you're iterating over token with a foreach, in this case, you won't need to get token as well since the foreach element would have done that for you. You can try the other iterator elements too, but consult the user's manual if you haven't used them before, as their syntax may not be what you expect. -- Bruce Ide flyingrhenqu...@gmail.com
Re: Storing values in an Array
Won't the "var.put" overwrite the previous value in "userCounter"? What I need to do is, after each user logs in they will receive a unique token from the server: Token 1: adfkdkdkfja1234 Token 2: 234ksk343ksldf3 Token 3: kfkdf225699 Token 4: 45k6k5k40s Token 5: kk4k4k4k55 I need to be able to store them in one variable such that when I feed the variable to the for-each loop it can reference each token individually. -- View this message in context: http://jmeter.512774.n5.nabble.com/Storing-values-in-an-Array-tp4747712p4747928.html Sent from the JMeter - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: jmeter-user-unsubscr...@jakarta.apache.org For additional commands, e-mail: jmeter-user-h...@jakarta.apache.org
Re: Storing values in an Array
I usually end up making a user defined variable userCounter = 1 and then increment it as part of a BSF sampler inside the loop; int counter = ${userCounter}; // or Integer.parseInt(vars.get("userCounter")); counter = counter + 1; vars.put("userCounter", Integer.toString(counter)); You could probably do this in an __eval or __javascript or something, but I don't know if it really buys you any more or less trying to do it that way. I tend to prefer BSF samplers (With Groovy) for being more readiable. To a java programmer anyway... -- Bruce Ide flyingrhenqu...@gmail.com