numFIles is an Integer.

I've made a workaround on this by generating a random 0-1 million, creating a 
fraction, and then multiplying by my original value.  Just a workout, but works 
in my case.


-----Original Message-----
From: LERBSCHER JEAN-PIERRE <jler...@hotmail.com>
Sent: Monday, August 27, 2018 3:13 AM
To: JMeter Users List <user@jmeter.apache.org>
Subject: RE: Passing variables to Random function

Hi,

Is numFiles an expression?

There is a gap in user manual between eval function and evalVar function.


Variables       
eval<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjmeter.apache.org%2Fusermanual%2Ffunctions.html%23__eval&amp;data=02%7C01%7CDavid.Fertig%40navihealth.com%7C065d5908de1a45f21ad008d60bec951b%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636709508094251230&amp;sdata=Sls%2BioMpQ7866EyE%2Falv0A%2Fex7Ix52TzgguUZELRHbU%3D&amp;reserved=0>
        evaluate a variable expression  2.3.1
Variables       
evalVar<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjmeter.apache.org%2Fusermanual%2Ffunctions.html%23__evalVar&amp;data=02%7C01%7CDavid.Fertig%40navihealth.com%7C065d5908de1a45f21ad008d60bec951b%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636709508094251230&amp;sdata=l%2FQaMA6czWkYhHefPHwsM9Wh%2BmlLqTQGOjlgjT5N3VE%3D&amp;reserved=0>
  evaluate an expression stored in a variable     2.3.1



________________________________
De : David Fertig <david.fer...@navihealth.com> Envoyé : jeudi 23 août 2018 
17:34 À : JMeter Users List Objet : RE: Passing variables to Random function

>${__Random(0,${__evalVar(numFiles)})}

Unfortunately this also does not work.

2018-08-23 11:32:53,096 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.NumberFormatException: For input string: ""



-----Original Message-----
From: Felix Schumacher <felix.schumac...@internetallee.de>
Sent: Wednesday, August 22, 2018 11:14 AM
To: user@jmeter.apache.org
Subject: Re: Passing variables to Random function



Am 22.08.2018 um 17:06 schrieb Felix Schumacher:
>
>
> Am 21.08.2018 um 21:32 schrieb David Fertig:
>> I have a variable called numFiles, which I can print and verify
>> contains an integer.
>> Integer numFiles = vars.getObject("numFiles");
>>
>> I want to make a random number between 0 and that value.  But all of
>> the following fail ${__Random(0,__ ${numFiles},docIndex)};
>>
>> Integer docIndex  = ${__Random(0,${numFiles})};
>>
>> ${__Random(0,__ numFiles,docIndex)};
>>
>> Integer docIndex  = ${__Random(0,numFiles)};
>>
>> All with an errors like:
>> Uncaught Exception java.lang.NumberFormatException: For input string:
>> "${NUMFILES}". See log file for details.
>>
>> Uncaught Exception java.lang.NumberFormatException: For input string:
>> "numFiles". See log file for details.
>>
>> How do I pass a variable into the random() function?
> It seems that this is a bug. At the moment the Strings given to
> __Random will not be evaluated (and therefore the Integer will not be
> transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter will 
currently transform those values by itself (yet?).

To answer your question, you could use __evalVar function to convert your 
Integer into a String:

${__Random(0,${__evalVar(numFiles)})}

Regards,
  Feli


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

This email, including attachments, may contain information that is privileged, 
confidential or is exempt from disclosure under applicable law (including, but 
not limited to, protected health information). It is not intended for 
transmission to, or receipt by, any unauthorized persons. If the reader of this 
message is not the intended recipient, or the employee or agent responsible for 
delivering the message to the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this communication is strictly 
prohibited. If you believe this email was sent to you in error, do not read it. 
Please notify the sender immediately informing them of the error and delete all 
copies and attachments of the message from your system. Thank you.

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

This email, including attachments, may contain information that is privileged, 
confidential or is exempt from disclosure under applicable law (including, but 
not limited to, protected health information). It is not intended for 
transmission to, or receipt by, any unauthorized persons. If the reader of this 
message is not the intended recipient, or the employee or agent responsible for 
delivering the message to the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this communication is strictly 
prohibited. If you believe this email was sent to you in error, do not read it. 
Please notify the sender immediately informing them of the error and delete all 
copies and attachments of the message from your system. Thank you.

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

Reply via email to