Modified: jmeter/trunk/docs/usermanual/functions.html URL: http://svn.apache.org/viewvc/jmeter/trunk/docs/usermanual/functions.html?rev=1739469&r1=1739468&r2=1739469&view=diff ============================================================================== --- jmeter/trunk/docs/usermanual/functions.html (original) +++ jmeter/trunk/docs/usermanual/functions.html Sat Apr 16 14:36:00 2016 @@ -1,23 +1,12 @@ <!DOCTYPE html SYSTEM "about:legacy-compat"> <html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-15"><title>Apache JMeter - - User's Manual: Functions and Variables</title><meta name="viewport" content="width=device-width, initial-scale=1"><link href="http://fonts.googleapis.com/css?family=Merriweather:400normal" rel="stylesheet" type="text/css"><link rel="stylesheet" type="text/css" href="../css/new-style.css"></head><body role="document"><a href="#content" class="hidden">Main content</a><div class="header"><!-- + User's Manual: Functions and Variables</title><meta name="viewport" content="width=device-width, initial-scale=1"><link href="http://fonts.googleapis.com/css?family=Merriweather:400normal" rel="stylesheet" type="text/css"><link rel="stylesheet" type="text/css" href="../css/new-style.css"><link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png"><link rel="icon" href="../images/favicon.png"><meta name="msapplication-TileColor" content="#ffffff"><meta name="msapplication-TileImage" content="../images/mstile-144x144.png"><meta name="theme-color" content="#ffffff"></head><body role="document"><a href="#content" class="hidden">Main content</a><div class="header"><!-- APACHE LOGO - --><div><a href="http://www.apache.org"><img title="Apache Software Foundation" width="290" height="75" src="../images/asf-logo.png" alt="Logo ASF"></a></div><!-- + --><div><a href="http://www.apache.org"><img title="Apache Software Foundation" class="logo" src="../images/asf-logo.svg" alt="Logo ASF"></a></div><!-- PROJECT LOGO - --><div><a href="http://jmeter.apache.org/"><img src="../images/logo.jpg" alt="Apache JMeter"></a></div><div class="twitter"><div><a href="https://twitter.com/share" class="twitter-share-button" data-text="Powerful Load Testing with Apache #JMeter" data-via="ApacheJMeter" data-lang="en-gb" data-size="large">Tweet</a><script> - (function(d,s,id){ - var js, - fjs=d.getElementsByTagName(s)[0], - p=/^http:/.test(d.location)?'http':'https'; - if (!d.getElementById(id)) { - js=d.createElement(s); - js.id=id; - js.src=p+'://platform.twitter.com/widgets.js'; - fjs.parentNode.insertBefore(js,fjs); - } - })(document, 'script', 'twitter-wjs'); - </script></div><div><a href="https://twitter.com/ApacheJMeter" class="twitter-follow-button" data-show-count="false" data-lang="en-gb" data-size="large">Follow</a><script>(function(d,s,id){ + --><div><a href="http://jmeter.apache.org/"><img class="logo" src="../images/logo.svg" alt="Apache JMeter"></a></div><div class="banner"><iframe src="http://www.apache.org/ads/bannerbar.html" style="border-width:0;" frameborder="0" scrolling="no"></iframe><div class="clear"></div></div></div><div class="nav"><div class="social menu"><div><a href="https://twitter.com/share" class="twitter-share-button" data-text="Powerful Load Testing with Apache #JMeter" data-via="ApacheJMeter" data-lang="en-gb" data-size="large">Tweet</a><script> + (function(d,s,id){ var js, fjs=d.getElementsByTagName(s)[0], p=/^http:/.test(d.location)?'http':'https'; @@ -27,8 +16,19 @@ js.src=p+'://platform.twitter.com/widgets.js'; fjs.parentNode.insertBefore(js,fjs); } - })(document, 'script', 'twitter-wjs'); - </script></div></div><div class="banner"><iframe src="http://www.apache.org/ads/bannerbar.html" style="border-width:0;" frameborder="0" scrolling="no"></iframe><div class="clear"></div></div></div><div class="nav"><ul class="menu"><li><div class="menu-title">About</div><ul><li><a href="../index.html">Overview</a></li><li><a href="http://twitter.com/ApacheJMeter">JMeter on Twitter<img src="../images/twitter.png" alt="Icon for JMeter on Twitter"></a></li><li><a href="../issues.html">Issue Tracking</a></li><li><a href="http://projects.apache.org/feeds/rss/jmeter.xml">Subscribe to What's New</a></li><li><a href="http://www.apache.org/licenses/">License</a></li></ul></li></ul><ul class="menu"><li><div class="menu-title">Download</div><ul><li><a href="../download_jmeter.cgi">Download Releases</a></li><li><a href="../nightly.html">Developer (Nightly) Builds</a></li></ul></li></ul><ul class="menu"><li><div class="menu-title">Documentation</div><ul><li><a href="../changes.html" >Changes per version</a></li><li><a href="../usermanual/get-started.html">Get >Started</a></li><li><a href="../usermanual/index.html">User >Manual</a></li><li><a href="../usermanual/best-practices.html">Best >Practices</a></li><li><a >href="../usermanual/component_reference.html">Component >Reference</a></li><li><a href="../usermanual/functions.html">Functions >Reference</a></li><li><a href="../api/index.html">Javadocs</a></li><li><a >href="../building.html">Building JMeter and Add-Ons</a></li><li><a >href="http://wiki.apache.org/jmeter">JMeter Wiki</a></li><li><a >href="http://wiki.apache.org/jmeter/JMeterFAQ">FAQ >(Wiki)</a></li></ul></li></ul><ul class="menu"><li><div >class="menu-title">Tutorials (PDF format)</div><ul><li><a >href="../usermanual/jmeter_distributed_testing_step_by_step.pdf">Distributed >Testing</a></li><li><a >href="../usermanual/jmeter_proxy_step_by_step.pdf">Recording >Tests</a></li><li><a href="../usermanual/junitsampler_tutorial.pdf">JUnit >Sampler</a></li><li><a href="../us ermanual/jmeter_accesslog_sampler_step_by_step.pdf">Access Log Sampler</a></li><li><a href="../extending/jmeter_tutorial.pdf">Extending JMeter</a></li></ul></li></ul><ul class="menu"><li><div class="menu-title">Community</div><ul><li><a href="http://wiki.apache.org/jmeter/JMeterCommitters">Contributors</a></li><li><a href="../mail.html">Mailing Lists</a></li><li><a href="../svnindex.html">SVN Repositories</a></li></ul></li></ul><ul class="menu"><li><div class="menu-title">Foundation</div><ul><li><a href="http://www.apache.org/">ASF</a></li><li><a href="http://www.apache.org/foundation/getinvolved.html">Get Involved in the ASF</a></li><li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></li></ul></div><div class="main" id="content"><ul class="pagelinks"><li><a href="component_reference.html">< Prev</a></li><li><a href="../index.html">Index</a></li><li><a href="regular_exp ressions.html">Next ></a></li></ul><div class="section"><h1 id="functions">19. Functions and Variables<a class="sectionlink" href="#functions" title="Link to here">¶</a></h1> + })(document, 'script', 'twitter-wjs'); + </script></div><div><a href="https://twitter.com/ApacheJMeter" class="twitter-follow-button" data-show-count="false" data-lang="en-gb" data-size="large">Follow</a><script>(function(d,s,id){ + var js, + fjs=d.getElementsByTagName(s)[0], + p=/^http:/.test(d.location)?'http':'https'; + if (!d.getElementById(id)) { + js=d.createElement(s); + js.id=id; + js.src=p+'://platform.twitter.com/widgets.js'; + fjs.parentNode.insertBefore(js,fjs); + } + })(document, 'script', 'twitter-wjs'); + </script></div><div><a href="https://github.com/apache/jmeter"><img alt="star this repo" src="http://githubbadges.com/star.svg?user=apache&repo=jmeter&style=default"></a></div><div><a href="https://github.com/apache/jmeter/fork"><img alt="fork this repo" src="http://githubbadges.com/fork.svg?user=apache&repo=jmeter&style=default"></a></div><div><a href="https://maven-badges.herokuapp.com/maven-central/org.apache.jmeter/ApacheJMeter"><img alt="Maven Central" src="https://maven-badges.herokuapp.com/maven-central/org.apache.jmeter/ApacheJMeter/badge.png"></a></div></div><ul class="menu"><li onClick="return true"><div class="menu-title">About</div><ul><li><a href="../index.html">Overview</a></li><li><a href="http://www.apache.org/licenses/">License</a></li></ul></li></ul><ul class="menu"><li onClick="return true"><div class="menu-title">Download</div><ul><li><a href="../download_jmeter.cgi">Download Releases</a></li><li><a href="../nightly.html">Developer (Nightly) Builds</a></li></ul></li></ul><ul class="menu"><li onClick="return true"><div class="menu-title">Documentation</div><ul><li><a href="../changes.html">Changes per version</a></li><li><a href="../usermanual/get-started.html">Get Started</a></li><li><a href="../usermanual/index.html">User Manual</a></li><li><a href="../usermanual/best-practices.html">Best Practices</a></li><li><a href="../usermanual/component_reference.html">Component Reference</a></li><li><a href="../usermanual/functions.html">Functions Reference</a></li><li><a href="../api/index.html">Javadocs</a></li><li><a href="../building.html">Building JMeter and Add-Ons</a></li><li><a href="http://wiki.apache.org/jmeter">JMeter Wiki</a></li><li><a href="http://wiki.apache.org/jmeter/JMeterFAQ">FAQ (Wiki)</a></li></ul></li></ul><ul class="menu"><li onClick="return true"><div class="menu-title">Tutorials (PDF format)</div><ul><li><a href="../usermanual/jmeter_distributed_testing_step_by_step.pdf">Distributed Testing</a ></li><li><a href="../usermanual/jmeter_proxy_step_by_step.pdf">Recording >Tests</a></li><li><a href="../usermanual/junitsampler_tutorial.pdf">JUnit >Sampler</a></li><li><a >href="../usermanual/jmeter_accesslog_sampler_step_by_step.pdf">Access Log >Sampler</a></li><li><a href="../extending/jmeter_tutorial.pdf">Extending >JMeter</a></li></ul></li></ul><ul class="menu"><li onClick="return true"><div >class="menu-title">Community</div><ul><li><a href="../issues.html">Issue >Tracking</a></li><li><a href="../mail.html">Mailing Lists</a></li><li><a >href="../svnindex.html">Source Repositories</a></li><li><a >href="../building.html">Building and Contributing</a></li><li><a >href="https://projects.apache.org/project.html?jmeter">Project info at >Apache</a></li><li><a >href="http://wiki.apache.org/jmeter/JMeterCommitters">Contributors</a></li></ul></li></ul><ul > class="menu"><li onClick="return true"><div >class="menu-title">Foundation</div><ul><li><a >href="http://www.apache.org/">ASF</a></li><li><a href= "http://www.apache.org/foundation/getinvolved.html">Get Involved in the ASF</a></li><li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></li></ul></div><div class="main" id="content"><ul class="pagelinks"><li><a href="component_reference.html">< Prev</a></li><li><a href="../index.html">Index</a></li><li><a href="regular_expressions.html">Next ></a></li></ul><div class="section"><h1 id="functions">21. Functions and Variables<a class="sectionlink" href="#functions" title="Link to here">¶</a></h1> <p> JMeter functions are special values that can populate fields of any Sampler or other element in a test tree. A function call looks like this:</p> @@ -38,23 +38,23 @@ element in a test tree. A function call <p> Where "__functionName" matches the name of a function. <br> -Parentheses surround the parameters sent to the function, for example ${__time(YMD)} -The actual parameters vary from function to function. -Functions that require no parameters can leave off the parentheses, for example ${__threadNum}. +Parentheses surround the parameters sent to the function, for example <span class="code">${__time(YMD)}</span> +The actual parameters vary from function to function. +Functions that require no parameters can leave off the parentheses, for example <span class="code">${__threadNum}</span>. </p> <p> -If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter. +If a function parameter contains a comma, then be sure to escape this with "<span class="code">\</span>", otherwise JMeter will treat it as a parameter delimiter. For example: -<pre> +<pre class="source"> ${__time(EEE\, d MMM yyyy)} </pre> If the comma is not escaped - e.g. <span class="code">${__javaScript(Math.max(2,5))}</span> - you will get an error such as: -<pre> +<pre class="source"> ERROR - jmeter.functions.JavaScript: Error processing Javascript: [Math.max(2] org.mozilla.javascript.EvaluatorException: missing ) after argument list (<cmd>#1) </pre> - This is because the string "Math.max(2,5)" is treated as being two parameters to the __javascript function:<br> + This is because the string "<span class="code">Math.max(2,5)</span>" is treated as being two parameters to the __javascript function:<br> <span class="code">Math.max(2</span> and <span class="code">5)</span><br> Other error messages are possible. </p> @@ -66,24 +66,25 @@ ${VARIABLE} <p> <b> If an undefined function or variable is referenced, JMeter does not report/log an error - the reference is returned unchanged. -For example if UNDEF is not defined as a variable, then the value of ${UNDEF} is ${UNDEF}. +For example if <span class="code">UNDEF</span> is not defined as a variable, then the value of <span class="code">${UNDEF}</span> is <span class="code">${UNDEF}</span>. </b> Variables, functions (and properties) are all case-sensitive. <b> -Versions of JMeter after 2.3.1 trim spaces from variable names before use, so for example -${__Random(1,63, LOTTERY )} will use the variable 'LOTTERY' rather than ' LOTTERY '. +JMeter trims spaces from variable names before use, so for example +<span class="code">${__Random(1,63, LOTTERY )}</span> will use the variable '<span class="code">LOTTERY</span>' rather than '<span class="code"> LOTTERY </span>'. </b> </p> <div class="clear"></div><div class="note"> Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, -and need to be referenced using the __P or __property function. +and need to be referenced using the <span class="code">__P</span> or <span class="code">__property</span> function. </div><div class="clear"></div> <div class="clear"></div><div class="note"> -When using \ before a variable for a windows path for example C:\test\${test}, ensure you escape the \ otherwise JMeter will not interpret the variable, example: -C:\\test\\${test}. +When using <span class="code">\</span> before a variable for a windows path for example <span class="code">C:\test\${test}</span>, ensure you escape the <span class="code">\</span> +otherwise JMeter will not interpret the variable, example: +<span class="code">C:\\test\\${test}</span>. <br> -Alternatively, just use / instead for the path separator - e.g. C:/test/${test} - Windows JVMs will convert the separators as necessary. +Alternatively, just use <span class="code">/</span> instead for the path separator - e.g. <span class="code">C:/test/${test}</span> - Windows JVMs will convert the separators as necessary. </div><div class="clear"></div> <p>List of functions, loosely grouped into types.</p> <table> @@ -109,7 +110,9 @@ Alternatively, just use / instead for th <tr><td>Calculation</td><td> <a href="#__UUID">UUID</a></td><td>generate a random type 4 UUID</td><td>2.9</td></tr> <tr><td>Scripting</td><td> <a href="#__BeanShell">BeanShell</a></td><td>run a BeanShell script</td><td>1.X</td></tr> <tr><td>Scripting</td><td> <a href="#__javaScript">javaScript</a></td><td>process JavaScript (Mozilla Rhino)</td><td>1.9</td></tr> - <tr><td>Scripting</td><td> <a href="#__jexl">jexl, jexl2</a></td><td>evaluate a Commons Jexl expression</td><td>jexl(2.2), jexl2(2.6)</td></tr> + <tr><td>Scripting</td><td> <a href="#__jexl">jexl</a></td><td>evaluate a Commons Jexl expression. This function is DEPRECATED as of JMeter 3.0, it will be removed in 3.1 version.</td><td>jexl1(1.1)</td></tr> + <tr><td>Scripting</td><td> <a href="#__jexl2">jexl2</a></td><td>evaluate a Commons Jexl2 expression</td><td>jexl2(2.1.1)</td></tr> + <tr><td>Scripting</td><td> <a href="#__jexl3">jexl3</a></td><td>evaluate a Commons Jexl3 expression</td><td>jexl3 (3.0)</td></tr> <tr><td>Properties</td><td> <a href="#__property">property</a> </td><td>read a property</td><td>2.0</td></tr> <tr><td>Properties</td><td> <a href="#__P">P</a></td><td>read a property (shorthand method)</td><td>2.0</td></tr> <tr><td>Properties</td><td> <a href="#__setProperty">setProperty</a></td><td>set a JMeter property</td><td>2.1</td></tr> @@ -120,7 +123,7 @@ Alternatively, just use / instead for th <tr><td>String</td><td> <a href="#__regexFunction">regexFunction</a></td><td>parse previous response using a regular expression</td><td>1.X</td></tr> <tr><td>String</td><td> <a href="#__escapeOroRegexpChars">escapeOroRegexpChars</a></td><td>quote meta chars used by ORO regular expression</td><td>2.9</td></tr> <tr><td>String</td><td> <a href="#__char">char</a></td><td>generate Unicode char values from a list of numbers</td><td>2.3.3</td></tr> - <tr><td>String</td><td> <a href="#__unescape">unescape</a></td><td>Process strings containing Java escapes (e.g. \n & \t)</td><td>2.3.3</td></tr> + <tr><td>String</td><td> <a href="#__unescape">unescape</a></td><td>Process strings containing Java escapes (e.g. \n & \t)</td><td>2.3.3</td></tr> <tr><td>String</td><td> <a href="#__unescapeHtml">unescapeHtml</a></td><td>Decode HTML-encoded strings</td><td>2.3.3</td></tr> <tr><td>String</td><td> <a href="#__escapeHtml">escapeHtml</a></td><td>Encode strings using HTML encoding</td><td>2.3.3</td></tr> <tr><td>String</td><td> <a href="#__urldecode">urldecode</a></td><td>Decode a application/x-www-form-urlencoded string</td><td>2.10</td></tr> @@ -128,7 +131,7 @@ Alternatively, just use / instead for th <tr><td>String</td><td> <a href="#__TestPlanName">TestPlanName</a></td><td>Return name of current test plan</td><td>2.6</td></tr> </table> <p></p> -<div class="subsection"><h2>19.1 What can functions do<a class="sectionlink" href="#what_can_do" title="Link to here">¶</a></h2> +<div class="subsection"><h2 id="what_can_do">21.1 What can functions do<a class="sectionlink" href="#what_can_do" title="Link to here">¶</a></h2> <p>There are two kinds of functions: user-defined static values (or variables), and built-in functions.<br> User-defined static values allow the user to define variables to be replaced with their static value when a test tree is compiled and submitted to be run. This replacement happens once at the beginning of the test @@ -136,9 +139,9 @@ run. This could be used to replace the matter to change a test to target a different server with the same test. </p> <p> -Note that variables cannot currently be nested; i.e ${Var${N}} does not work. -The __V (variable) function (versions after 2.2) can be used to do this: ${__V(Var${N})}. -In earlier JMeter versions one can use ${__BeanShell(vars.get("Var${N}")}. +Note that variables cannot currently be nested; i.e. <span class="code">${Var${N}}</span> does not work. +The <span class="code">__V</span> (variable) function can be used to do this: <span class="code">${__V(Var${N})}</span>. +You can also use <span class="code">${__BeanShell(vars.get("Var${N}")}</span>. </p> <p>This type of replacement is possible without functions, but was less convenient and less intuitive. It required users to create default config elements that would fill in blank values of Samplers. @@ -151,7 +154,7 @@ request throughout the course of the tes Each occurrence of a function call in a test plan is handled by a separate function instance.</div><div class="clear"></div> </div> -<div class="subsection"><h2>19.2 Where can functions and variables be used?<a class="sectionlink" href="#where" title="Link to here">¶</a></h2> +<div class="subsection"><h2 id="where">21.2 Where can functions and variables be used?<a class="sectionlink" href="#where" title="Link to here">¶</a></h2> <p> Functions and variables can be written into any field of any test component (apart from the TestPlan - see below). Some fields do not allow random strings @@ -162,8 +165,8 @@ functions. Functions which are used on the Test Plan have some restrictions. JMeter thread variables will have not been fully set up when the functions are processed, so variable names passed as parameters will not be set up, and variable references will not work, -so split() and regex() and the variable evaluation functions won't work. -The threadNum() function won't work (and does not make sense at test plan level). +so <span class="code">split()</span> and <span class="code">regex()</span> and the variable evaluation functions won't work. +The <span class="code">threadNum()</span> function won't work (and does not make sense at test plan level). The following functions should work OK on the test plan: <ul> <li>intSum</li> @@ -180,48 +183,51 @@ The following functions should work OK o </p> <p> Configuration elements are processed by a separate thread. -Therefore functions such as __threadNum do not work properly in elements such as User Defined Variables. +Therefore functions such as <span class="code">__threadNum</span> do not work properly in elements such as User Defined Variables. Also note that variables defined in a UDV element are not available until the element has been processed. </p> -<div class="clear"></div><div class="note">When using variable/function references in SQL code (etc), +<div class="clear"></div><div class="note">When using variable/function references in SQL code (etc.), remember to include any necessary quotes for text strings, -i.e. use<br> +i.e. use +<pre class="source"> SELECT item from table where name='${VAR}' -<br><b>not</b> -<br> +</pre> +<b>not</b> +<pre class="source"> SELECT item from table where name=${VAR} -<br>(unless VAR itself contains the quotes) +</pre> +(unless <span class="code">VAR</span> itself contains the quotes) </div><div class="clear"></div> </div> -<div class="subsection"><h2>19.3 How to reference variables and functions<a class="sectionlink" href="#how" title="Link to here">¶</a></h2> -<p>Referencing a variable in a test element is done by bracketing the variable name with '${' and '}'.</p> +<div class="subsection"><h2 id="how">21.3 How to reference variables and functions<a class="sectionlink" href="#how" title="Link to here">¶</a></h2> +<p>Referencing a variable in a test element is done by bracketing the variable name with '<span class="code">${</span>' and '<span class="code">}</span>'.</p> <p>Functions are referenced in the same manner, but by convention, the names of -functions begin with "__" to avoid conflict with user value names<sup>*</sup>. Some functions take arguments to +functions begin with "<span class="code">__</span>" to avoid conflict with user value names<sup>*</sup>. Some functions take arguments to configure them, and these go in parentheses, comma-delimited. If the function takes no arguments, the parentheses can be omitted.</p> <p><b>Argument values that themselves contain commas should be escaped as necessary. -If you need to include a comma in your parameter value, escape it like so: '\,'.</b> +If you need to include a comma in your parameter value, escape it like so: '<span class="code">\,</span>'.</b> This applies for example to the scripting functions - Javascript, Beanshell, Jexl - where it is necessary to escape any commas that may be needed in script method calls - e.g. </p> <pre> - ${__BeanShell(vars.put("name"\,"value"))} +${__BeanShell(vars.put("name"\,"value"))} </pre> <p> Alternatively, you can define your script as a variable, e.g. on the Test Plan: <pre>SCRIPT vars.put("name","value")</pre> The script can then be referenced as follows: <pre>${__BeanShell(${SCRIPT})}</pre> -There is no need to escape commas in the SCRIPT variable because the function call is parsed before the variable is replaced with its value. +There is no need to escape commas in the <span class="code">SCRIPT</span> variable because the function call is parsed before the variable is replaced with its value. This works well in conjunction with the BSF or BeanShell Samplers, as these can be used to test Javascript, Jexl and BeanShell scripts. </p> <p> Functions can reference variables and other functions, for example <span class="code">${__XPath(${__P(xpath.file),${XPATH})}</span> -will use the property "xpath.file" as the file name -and the contents of the variable XPATH as the expression to search for. +will use the property "<span class="code">xpath.file</span>" as the file name +and the contents of the variable <span class="code">XPATH</span> as the expression to search for. </p> <p> JMeter provides a tool to help you construct @@ -229,24 +235,24 @@ function calls for various built-in func It will not automatically escape values for you, since functions can be parameters to other functions, and you should only escape values you intend as literal. </p> <div class="clear"></div><div class="note"> -If a string contains a backslash('\') and also contains a function or variable reference, the backslash will be removed if -it appears before '$' or ',' or '\'. -This behaviour is necessary to allow for nested functions that include commas or the string ${. -Backslashes before '$' or ',' or '\' are not removed if the string does not contain a function or variable reference. +If a string contains a backslash('<span class="code">\</span>') and also contains a function or variable reference, the backslash will be removed if +it appears before '<span class="code">$</span>' or '<span class="code">,</span>' or '<span class="code">\</span>'. +This behaviour is necessary to allow for nested functions that include commas or the string <span class="code">${</span>. +Backslashes before '<span class="code">$</span>' or '<span class="code">,</span>' or '<span class="code">\</span>' are not removed if the string does not contain a function or variable reference. </div><div class="clear"></div> <p> -<b>The value of a variable or function can be reported</b> using the <a href="#__logn">__logn()</a> function. -The __logn() function reference can be used anywhere in the test plan after the variable has been defined. +<b>The value of a variable or function can be reported</b> using the <a href="#__logn"><span class="code">__logn()</span></a> function. +The <span class="code">__logn()</span> function reference can be used anywhere in the test plan after the variable has been defined. Alternatively, the Java Request sampler can be used to create a sample containing variable references; the output will be shown in the appropriate Listener. -For versions of JMeter later than 2.3, there is a <a href="../usermanual/component_reference.html#Debug_Sampler">Debug Sampler</a> -that can be used to display the values of variables etc in the Tree View Listener. +Note there is a <a href="../usermanual/component_reference.html#Debug_Sampler">Debug Sampler</a> +that can be used to display the values of variables etc. in the Tree View Listener. </p> <div class="clear"></div><div class="note"><sup>*</sup>If you define a user-defined static variable with the same name as a built-in function, your static variable will override the built-in function.</div><div class="clear"></div> </div> -<div class="subsection"><h2>19.4 The Function Helper Dialog<a class="sectionlink" href="#function_helper" title="Link to here">¶</a></h2> +<div class="subsection"><h2 id="function_helper">21.4 The Function Helper Dialog<a class="sectionlink" href="#function_helper" title="Link to here">¶</a></h2> <p>The Function Helper dialog is available from JMeter's Tools menu.</p> <figure><a href="../images/screenshots/function_helper_dialog.png"><img src="../images/screenshots/function_helper_dialog.png" width="831" height="305" alt="Function Helper Dialog"></a><figcaption>Function Helper Dialog</figcaption></figure> <p>Using the Function Helper, you can select a function from the pull down, and assign @@ -257,157 +263,146 @@ functions take different arguments.</p> for you to copy-paste into your test plan wherever you like.</p> </div> -<div class="subsection"><h2>19.5 Functions<a class="sectionlink" href="#functions" title="Link to here">¶</a></h2> +<div class="subsection"><h2 id="functions">21.5 Functions<a class="sectionlink" href="#functions" title="Link to here">¶</a></h2> -<div class="component"><h2 id="__regexFunction">__regexFunction<a class="sectionlink" href="#__regexFunction" title="Link to here">¶</a></h2> -<div class="description"><p>The Regex Function is used to parse the previous response (or the value of a variable) using any regular +<div class="component"><h2 id="__regexFunction">__regexFunction<a class="sectionlink" href="#__regexFunction" title="Link to here">¶</a></h2><div class="description"><p>The Regex Function is used to parse the previous response (or the value of a variable) using any regular expression (provided by user). The function returns the template string with variable values filled in.</p> -<p>The __regexFunction can also store values for future use. In the sixth parameter, you can specify +<p>The <span class="code">__regexFunction</span> can also store values for future use. In the sixth parameter, you can specify a reference name. After this function executes, the same values can be retrieved at later times -using the syntax for user-defined values. For instance, if you enter "refName" as the sixth +using the syntax for user-defined values. For instance, if you enter "<span class="code">refName</span>" as the sixth parameter you will be able to use: <ul> -<li>${refName} to refer to the computed result of the second parameter ("Template for the +<li><span class="code">${refName}</span> to refer to the computed result of the second parameter ("Template for the replacement string") parsed by this function</li> -<li>${refName_g0} to refer to the entire match parsed by this function.</li> -<li>${refName_g1} to refer to the first group parsed by this function.</li> -<li>${refName_g#} to refer to the n<sup>th</sup> group parsed by this function.</li> -<li>${refName_matchNr} to refer to the number of groups found by this function.</li> +<li><span class="code">${refName_g0}</span> to refer to the entire match parsed by this function.</li> +<li><span class="code">${refName_g1}</span> to refer to the first group parsed by this function.</li> +<li><span class="code">${refName_g#}</span> to refer to the n<sup>th</sup> group parsed by this function.</li> +<li><span class="code">${refName_matchNr}</span> to refer to the number of groups found by this function.</li> </ul> -<div class="clear"></div><div class="note">If using distributed testing, ensure you switch mode (see jmeter.properties) so that it's not a stripping one, see <a href="http://bz.apache.org/bugzilla/show_bug.cgi?id=56376"> +<div class="clear"></div><div class="note">If using distributed testing, ensure you switch mode (see <span class="code">jmeter.properties</span>) so that it's not a stripping one, see <a href="http://bz.apache.org/bugzilla/show_bug.cgi?id=56376"> Bug 56376</a></div><div class="clear"></div> </p> -</div> - -<div class="properties"><h3 id="__regexFunction_parms1"> +</div><div class="properties"><h3 id="__regexFunction_parms1"> Parameters <a class="sectionlink" href="#__regexFunction_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">First argument</div><div class="description req-true">The first argument is the regular expression to be applied to the response data. It will grab all matches. Any parts of this expression that you wish to use in your template string, be sure to surround in parentheses. Example: - <a href="(.*)">. This will grab the value of the link and store it as the first group (there is - only 1 group). Another example: <input type="hidden" name="(.*)" value="(.*)">. This will + <span class="code"><a href="(.*)"></span>. This will grab the value of the link and store it as the first group (there is + only 1 group). Another example: <span class="code"><input type="hidden" name="(.*)" value="(.*)"></span>. This will grab the name as the first group, and the value as the second group. These values can be used in your template string</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-true">Second argument</div><div class="description req-true">This is the template string that will replace the function at run-time. To refer to a group captured in the regular expression, use the syntax: - $[group_number]$. Ie: $1$, or $2$. Your template can be any string.</div><div class="required req-true">Yes</div></div> + <span class="code">$[group_number]$</span>. I.e.: <span class="code">$1$</span>, or <span class="code">$2$</span>. Your template can be any string.</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Third argument</div><div class="description req-false">The third argument tells JMeter which match to use. Your regular expression might find numerous matches. You have four choices: - <ul><li>An integer - Tells JMeter to use that match. '1' for the first found match, '2' for the + <ul><li>An integer - Tells JMeter to use that match. '<span class="code">1</span>' for the first found match, '<span class="code">2</span>' for the second, and so on</li> - <li>RAND - Tells JMeter to choose a match at random.</li> - <li>ALL - Tells JMeter to use all matches, and create a template string for each one and then + <li><span class="code">RAND</span> - Tells JMeter to choose a match at random.</li> + <li><span class="code">ALL</span> - Tells JMeter to use all matches, and create a template string for each one and then append them all together. This option is little used.</li> - <li>A float number between 0 and 1 - tells JMeter to find the Xth match using the formula: + <li>A float number between 0 and 1 - tells JMeter to find the X<sup>th</sup> match using the formula: (number_of_matches_found * float_number) rounded to nearest integer.</li> </ul></div><div class="required req-false">No, default=1</div></div> - <div class="property"><div class="name req-false">Fourth argument</div><div class="description req-false">If 'ALL' was selected for the above argument + <div class="property"><div class="name req-false">Fourth argument</div><div class="description req-false">If '<span class="code">ALL</span>' was selected for the above argument value, then this argument will be inserted between each appended copy of the template value.</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Fifth argument</div><div class="description req-false">Default value returned if no match is found</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Sixth argument</div><div class="description req-false">A reference name for reusing the values parsed by this function.<br> - Stored values are ${refName} (the replacement template string) and ${refName_g#} where "#" is the - group number from the regular expression ("0" can be used to refer to the entire match).</div><div class="required req-false">No</div></div> + Stored values are <span class="code">${refName}</span> (the replacement template string) and <span class="code">${refName_g#}</span> where "<span class="code">#</span>" is the + group number from the regular expression ("<span class="code">0</span>" can be used to refer to the entire match).</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Seventh argument</div><div class="description req-false">Input variable name. If specified, then the value of the variable is used as the input instead of using the previous sample result. </div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> +</div><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__counter">__counter<a class="sectionlink" href="#__counter" title="Link to here">¶</a></h2> -<div class="description"><p>The counter generates a new number each time it is called, starting with 1 +<div class="component"><h2 id="__counter">__counter<a class="sectionlink" href="#__counter" title="Link to here">¶</a></h2><div class="description"><p>The counter generates a new number each time it is called, starting with 1 and incrementing by +1 each time. The counter can be configured to keep each simulated user's values separate, or to use the same counter for all users. If each user's values is incremented separately, that is like counting the number of iterations through the test plan. A global counter is like counting how many times that request was run. </p> <p>The counter uses an integer variable to hold the count, which therefore has a maximum of 2,147,483,647.</p> -<p>The counter function instances are now completely independent. -[JMeter 2.1.1 and earlier used a fixed thread variable to keep track of the per-user count, -so multiple counter functions operated on the same value.] -The global counter - "FALSE" - is separately maintained by each counter instance. +<p>The counter function instances are completely independent. +The global counter - "<span class="code">FALSE</span>" - is separately maintained by each counter instance. </p> <p> <b> -Multiple __counter function calls in the same iteration won't increment the value further. +Multiple <span class="code">__counter</span> function calls in the same iteration won't increment the value further. </b> <br> If you want to have a count that increments for each sample, use the function in a Pre-Processor such as <a href="../usermanual/component_reference.html#User_Parameters">User Parameters</a>. </p> -</div> -<div class="properties"><h3 id="__counter_parms1"> +</div><div class="properties"><h3 id="__counter_parms1"> Parameters <a class="sectionlink" href="#__counter_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> - <div class="property"><div class="name req-true">First argument</div><div class="description req-true">TRUE if you wish each simulated user's counter - to be kept independent and separate from the other users. FALSE for a global counter.</div><div class="required req-true">Yes</div></div> + <div class="property"><div class="name req-true">First argument</div><div class="description req-true"><span class="code">TRUE</span> if you wish each simulated user's counter + to be kept independent and separate from the other users. <span class="code">FALSE</span> for a global counter.</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Second argument</div><div class="description req-false">A reference name for reusing the value created by this function.<br> - Stored values are of the form ${refName}. This allows you to keep one counter and refer to its value in - multiple places. [For JMeter 2.1.1 and earlier this parameter was required.]</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> + Stored values are of the form <span class="code">${refName}</span>. This allows you to keep one counter and refer to its value in + multiple places.</div><div class="required req-false">No</div></div> +</div><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__threadNum">__threadNum<a class="sectionlink" href="#__threadNum" title="Link to here">¶</a></h2> -<div class="description"><p>The thread number function simply returns the number of the thread currently +<div class="component"><h2 id="__threadNum">__threadNum<a class="sectionlink" href="#__threadNum" title="Link to here">¶</a></h2><div class="description"><p>The thread number function simply returns the number of the thread currently being executed. These numbers are independent of ThreadGroup, meaning thread #1 in one threadgroup is indistinguishable from thread #1 in another threadgroup, from the point of view of this function.</p> <p>There are no arguments for this function.</p> -</div> -<div class="clear"></div><div class="note"> +<p>Usage Example: +<pre class="source">${__threadNum}</pre> returns a number between 1 and the max number of running threads configured in the containing Thread Group +</p> +</div><div class="clear"></div><div class="note"> This function does not work in any Configuration elements (e.g. User Defined Variables) as these are run from a separate thread. Nor does it make sense to use it on the Test Plan. -</div><div class="clear"></div> -<div class="go-top"><a href="#">^</a></div></div> +</div><div class="clear"></div><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__intSum">__intSum<a class="sectionlink" href="#__intSum" title="Link to here">¶</a></h2> -<div class="description"> +<div class="component"><h2 id="__intSum">__intSum<a class="sectionlink" href="#__intSum" title="Link to here">¶</a></h2><div class="description"> <p> The intSum function can be used to compute the sum of two or more integer values. </p> <div class="clear"></div><div class="note"> -JMeter Versions 2.3.1 and earlier required the reference name to be present. -The reference name is now optional, but it must not be a valid integer. +The reference name is optional, but it must not be a valid integer. </div><div class="clear"></div> -</div> - -<div class="properties"><h3 id="__intSum_parms1"> +</div><div class="properties"><h3 id="__intSum_parms1"> Parameters <a class="sectionlink" href="#__intSum_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">First argument</div><div class="description req-true">The first int value.</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-true">Second argument</div><div class="description req-true">The second int value.</div><div class="required req-true">Yes</div></div> - <div class="property"><div class="name req-false">nth argument</div><div class="description req-false">The nth int value.</div><div class="required req-false">No</div></div> + <div class="property"><div class="name req-false">nth argument</div><div class="description req-false">The n<sup>th</sup> int value.</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">last argument</div><div class="description req-false">A reference name for reusing the value computed by this function. If specified, the reference name must contain at least one non-numeric character otherwise it will be treated as another int value to be added. </div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> - -<div class="component"><h2 id="__longSum">__longSum<a class="sectionlink" href="#__longSum" title="Link to here">¶</a></h2> -<div class="description"><p>The longSum function can be used to compute the sum of two or more long values. -</p></div> - -<div class="properties"><h3 id="__longSum_parms1"> +</div><p>Examples: +<pre class="source">${__intSum(2,5,MYVAR)}</pre> will return 7 (2+5) and store the result in MYVAR variable. So <span class="code">${MYVAR}</span> will be equal to 7. <br> +<pre class="source">${__intSum(2,5,7)}</pre> will return 14 (2+5+7) and store the result in MYVAR variable. <br> +<pre class="source">${__intSum(1,2,5,${MYVAR})}</pre> will return 16 if MYVAR value is equal to 8, 1+2+5+${MYVAR})<br> +</p><div class="go-top"><a href="#">^</a></div></div> + +<div class="component"><h2 id="__longSum">__longSum<a class="sectionlink" href="#__longSum" title="Link to here">¶</a></h2><div class="description"><p>The longSum function can be used to compute the sum of two or more long values, use this instead of __intSum whenever you know your values will not +be in the interval -2147483648 to 2147483647. +</p></div><div class="properties"><h3 id="__longSum_parms1"> Parameters <a class="sectionlink" href="#__longSum_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">First argument</div><div class="description req-true">The first long value.</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-true">Second argument</div><div class="description req-true">The second long value.</div><div class="required req-true">Yes</div></div> - <div class="property"><div class="name req-false">nth argument</div><div class="description req-false">The nth long value.</div><div class="required req-false">No</div></div> + <div class="property"><div class="name req-false">nth argument</div><div class="description req-false">The n<sup>th</sup> long value.</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">last argument</div><div class="description req-false">A reference name for reusing the value computed by this function. If specified, the reference name must contain at least one non-numeric character otherwise it will be treated as another long value to be added. </div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> +</div><p>Examples: +<pre class="source">${__longSum(2,5,MYVAR)}</pre> will return 7 (2+5) and store the result in MYVAR variable. So <span class="code">${MYVAR}</span> will be equal to 7. <br> +<pre class="source">${__longSum(2,5,7)}</pre> will return 14 (2+5+7) and store the result in MYVAR variable. <br> +<pre class="source">${__longSum(1,2,5,${MYVAR})}</pre> will return 16 if MYVAR value is equal to 8, 1+2+5+${MYVAR})<br> +</p><div class="go-top"><a href="#">^</a></div></div> <a name="_StringFromFile"></a> -<div class="component"><h2 id="__StringFromFile">__StringFromFile<a class="sectionlink" href="#__StringFromFile" title="Link to here">¶</a></h2> - -<div class="description"> +<div class="component"><h2 id="__StringFromFile">__StringFromFile<a class="sectionlink" href="#__StringFromFile" title="Link to here">¶</a></h2><div class="description"> <p> The StringFromFile function can be used to read strings from a text file. This is useful for running tests that require lots of variable data. @@ -430,13 +425,11 @@ The reference name is now optional, but </p> <div class="clear"></div><div class="note"> Function instances are shared between threads, and the file is (re-)opened by whatever thread - happens to need the next line of input, so using the threadNumber as part of the file name + happens to need the next line of input, so using the <span class="code">threadNumber</span> as part of the file name will result in unpredictable behaviour. </div><div class="clear"></div> - <p>If an error occurs opening or reading the file, then the function returns the string "**ERR**"</p> -</div> - -<div class="properties"><h3 id="__StringFromFile_parms1"> + <p>If an error occurs opening or reading the file, then the function returns the string "<span class="code">**ERR**</span>"</p> +</div><div class="properties"><h3 id="__StringFromFile_parms1"> Parameters <a class="sectionlink" href="#__StringFromFile_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">File Name</div><div class="description req-true">Path to the file name. @@ -445,80 +438,74 @@ The reference name is now optional, but See below for examples. </div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false"> -A reference name - refName - for reusing the value created by this function. Stored values are of the form ${refName}. -Defaults to "StringFromFile_". +A reference name - <span class="code">refName</span> - for reusing the value created by this function. Stored values are of the form <span class="code">${refName}</span>. +Defaults to "<span class="code">StringFromFile_</span>". </div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Start sequence number</div><div class="description req-false">Initial Sequence number (if omitted, the End sequence number is treated as a loop count)</div><div class="required req-false">No</div></div> - <div class="property"><div class="name req-false">End sequence number</div><div class="description req-false">Final sequence number (if omitted, seqence numbers can increase without limit)</div><div class="required req-false">No</div></div> -</div> -<p>The file name parameter is resolved when the file is opened or re-opened.</p> -<p>The reference name parameter (if supplied) is resolved every time the function is executed.</p> -<p><b>Using sequence numbers:</b></p> -<p>When using the optional sequence numbers, the path name is used as the format string for java.text.DecimalFormat. + <div class="property"><div class="name req-false">End sequence number</div><div class="description req-false">Final sequence number (if omitted, sequence numbers can increase without limit)</div><div class="required req-false">No</div></div> +</div><p>The file name parameter is resolved when the file is opened or re-opened.</p><p>The reference name parameter (if supplied) is resolved every time the function is executed.</p><p><b>Using sequence numbers:</b></p><p>When using the optional sequence numbers, the path name is used as the format string for <span class="code">java.text.DecimalFormat</span>. The current sequence number is passed in as the only parameter. If the optional start number is not specified, the path name is used as is. Useful formatting sequences are: - </p> - <p> -<span class="code"> -# - insert the number, with no leading zeros or spaces<br> -000 - insert the number packed out to 3 digits with leading zeros if necessary -<p></p> -Examples:<br> - pin#'.'dat -> pin1.dat, ... pin9.dat, pin10.dat, ... pin9999.dat<br> - pin000'.'dat -> pin001.dat ... pin099.dat ... pin999.dat ... pin9999.dat<br> - pin'.'dat# -> pin.dat1, ... pin.dat9 ... pin.dat999 -</span><p></p> + </p><dl> +<dt><span class="code">#</span></dt><dd>insert the number, with no leading zeros or spaces</dd> +<dt><span class="code">000</span></dt><dd>insert the number packed out to three digits with leading zeros if necessary</dd> +</dl><div class="example"><div class="title">Usage of format strings<a class="sectionlink" href="#string-from-file-format-examples" title="Link to here">¶</a></div> +Here are a few format strings and the corresponding sequences they will generate. +<dl> + <dt><span class="code">pin#'.'dat</span></dt><dd>Will generate the digits without leading zeros and treat the dot literally like<br> + <span class="code">pin1.dat</span>, …, <span class="code">pin9.dat</span>, <span class="code">pin10.dat</span>, …, <span class="code">pin9999.dat</span></dd> + <dt><span class="code">pin000'.'dat</span></dt><dd>Will generate leading zeros while keeping the dot. When the numbers start having more digits + then those three digits that this format suggests, the sequence will use more digits as can be seen in<br> + <span class="code">pin001.dat</span>, … <span class="code">pin099.dat</span>, …, <span class="code">pin999.dat</span>, …, <span class="code">pin9999.dat</span></dd> + <dt><span class="code">pin'.'dat#</span></dt><dd>Will append digits without leading zeros while keeping the dot and generate<br> + <span class="code">pin.dat1</span>, …, <span class="code">pin.dat9</span>, …, <span class="code">pin.dat999</span></dd> +</dl> +</div><p> If more digits are required than there are formatting characters, the number will be expanded as necessary.<br> <b>To prevent a formatting character from being interpreted, - enclose it in single quotes. Note that "." is a formatting character, + enclose it in single quotes. Note that "<span class="code">.</span>" is a formatting character, and must be enclosed in single quotes</b> - (though #. and 000. work as expected in locales where the decimal point is also ".") + (though <span class="code">#.</span> and <span class="code">000.</span> work as expected in locales where the decimal point is also "<span class="code">.</span>") <br> - In other locales (e.g. fr), the decimal point is "," - which means that "#." - becomes "nnn,".<br> - See the documentation for DecimalFormat for full details.<br> + In other locales (e.g. <span class="code">fr</span>), the decimal point is "<span class="code">,</span>" - which means that "<span class="code">#.</span>" + becomes "<span class="code">nnn,</span>".<br> + See the documentation for <span class="code">DecimalFormat</span> for full details.<br> If the path name does not contain any special formatting characters, the current sequence number will be appended to the name, otherwise - the number will be inserted aaccording to the fomatting instructions.<br> + the number will be inserted according to the formatting instructions.<br> If the start sequence number is omitted, and the end sequence number is specified, - the sequence number is interpreted as a loop count, and the file will be used at most "end" times. + the sequence number is interpreted as a loop count, and the file will be used at most "<span class="code">end</span>" times. In this case the filename is not formatted. - <span class="code"> <br> - ${_StringFromFile(PIN#'.'DAT,,1,2)} - reads PIN1.DAT, PIN2.DAT<br> - ${_StringFromFile(PIN.DAT,,,2)} - reads PIN.DAT twice<br> - </span> - Note that the "." in PIN.DAT above should <u>not</u> be quoted. + <span class="code">${_StringFromFile(PIN#'.'DAT,,1,2)}</span> - reads <span class="code">PIN1.DAT</span>, <span class="code">PIN2.DAT</span><br> + <span class="code">${_StringFromFile(PIN.DAT,,,2)}</span> - reads <span class="code">PIN.DAT</span> twice<br> + Note that the "<span class="code">.</span>" in <span class="code">PIN.DAT</span> above should <u>not</u> be quoted. In this case the start number is omitted, so the file name is used exactly as is. - </p> -<div class="go-top"><a href="#">^</a></div></div> + </p><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__machineName">__machineName<a class="sectionlink" href="#__machineName" title="Link to here">¶</a></h2> -<div class="description"><p>The machineName function returns the local host name</p></div> - -<div class="properties"><h3 id="__machineName_parms1"> +<div class="component"><h2 id="__machineName">__machineName<a class="sectionlink" href="#__machineName" title="Link to here">¶</a></h2><div class="description"><p>The machineName function returns the local host name. This uses the Java method <span class="code">InetAddress.getLocalHost()</span> and passes it to <span class="code">getHostName()</span></p></div><div class="properties"><h3 id="__machineName_parms1"> Parameters <a class="sectionlink" href="#__machineName_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false">A reference name for reusing the value computed by this function.</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> - -<div class="component"><h2 id="__machineIP">__machineIP<a class="sectionlink" href="#__machineIP" title="Link to here">¶</a></h2> -<div class="description"><p>The machineIP function returns the local IP address</p></div> +</div><p>Examples: +<pre class="source">${__machineName()}</pre> will return the host name of the machine<br> +<pre class="source">${__machineName}</pre> will return the host name of the machine<br> +</p><div class="go-top"><a href="#">^</a></div></div> -<div class="properties"><h3 id="__machineIP_parms1"> +<div class="component"><h2 id="__machineIP">__machineIP<a class="sectionlink" href="#__machineIP" title="Link to here">¶</a></h2><div class="description"><p>The machineIP function returns the local IP address. This uses the Java method <span class="code">InetAddress.getLocalHost()</span> and passes it to <span class="code">getHostAddress()</span></p></div><div class="properties"><h3 id="__machineIP_parms1"> Parameters <a class="sectionlink" href="#__machineIP_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false">A reference name for reusing the value computed by this function.</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> +</div><p>Examples: +<pre class="source">${__machineIP()}</pre> will return the IP address of the machine<br> +<pre class="source">${__machineIP}</pre> will return the IP address of the machine<br> +</p><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__javaScript">__javaScript<a class="sectionlink" href="#__javaScript" title="Link to here">¶</a></h2> -<div class="description"> +<div class="component"><h2 id="__javaScript">__javaScript<a class="sectionlink" href="#__javaScript" title="Link to here">¶</a></h2><div class="description"> <p> The javaScript function executes a piece of JavaScript (not Java!) code and returns its value </p> @@ -532,13 +519,13 @@ For details of the language, please see The following variables are made available to the script: </p> <ul> -<li>log - the logger for the function</li> -<li>ctx - JMeterContext object</li> -<li>vars - JMeterVariables object</li> -<li>threadName - String containing the current thread name (in 2.3.2 it was misspelt as "theadName")</li> -<li>sampler - current Sampler object (if any)</li> -<li>sampleResult - previous SampleResult object (if any)</li> -<li>props - JMeter Properties object</li> +<li><span class="code">log</span> - the logger for the function</li> +<li><span class="code">ctx</span> - JMeterContext object</li> +<li><span class="code">vars</span> - JMeterVariables object</li> +<li><span class="code">threadName</span> - String containing the current thread name</li> +<li><span class="code">sampler</span> - current Sampler object (if any)</li> +<li><span class="code">sampleResult</span> - previous SampleResult object (if any)</li> +<li><span class="code">props</span> - JMeter Properties object</li> </ul> <p> Rhinoscript allows access to static methods via its Packages object. @@ -549,72 +536,71 @@ For example one can access the JMeterCon <div class="clear"></div><div class="note"> JMeter is not a browser, and does not interpret the JavaScript in downloaded pages. </div><div class="clear"></div> -</div> - -<div class="properties"><h3 id="__javaScript_parms1"> +</div><div class="properties"><h3 id="__javaScript_parms1"> Parameters <a class="sectionlink" href="#__javaScript_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">Expression</div><div class="description req-true">The JavaScript expression to be executed. For example: <ul> - <li>new Date() - return the current date and time</li> - <li>Math.floor(Math.random()*(${maxRandom}+1)) - - a random number between 0 and the variable maxRandom</li> - <li>${minRandom}+Math.floor(Math.random()*(${maxRandom}-${minRandom}+1)) - - a random number between the variables minRandom and maxRandom</li> - <li>"${VAR}"=="abcd"</li> + <li><span class="code">new Date()</span> - return the current date and time</li> + <li><span class="code">Math.floor(Math.random()*(${maxRandom}+1))</span> + - a random number between <span class="code">0</span> and the variable <span class="code">maxRandom</span></li> + <li><span class="code">${minRandom}+Math.floor(Math.random()*(${maxRandom}-${minRandom}+1))</span> + - a random number between the variables <span class="code">minRandom</span> and <span class="code">maxRandom</span></li> + <li><span class="code">"${VAR}"=="abcd"</span></li> </ul> </div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false">A reference name for reusing the value computed by this function.</div><div class="required req-false">No</div></div> -</div> -<div class="clear"></div><div class="note">Remember to include any necessary quotes for text strings and JMeter variables. Also, if +</div><div class="clear"></div><div class="note">Remember to include any necessary quotes for text strings and JMeter variables. Also, if the expression has commas, please make sure to escape them. For example in: -<br> +<pre class="source"> ${__javaScript('${sp}'.slice(7\,99999))} -<br> -the comma after 7 is escaped.</div><div class="clear"></div> -<div class="go-top"><a href="#">^</a></div></div> - -<div class="component"><h2 id="__Random">__Random<a class="sectionlink" href="#__Random" title="Link to here">¶</a></h2> -<div class="description"><p>The random function returns a random number that lies between the given min and max values.</p></div> +</pre> +the comma after <span class="code">7</span> is escaped.</div><div class="clear"></div><p>Examples: +<pre class="source">${__javaScript(new Date())}</pre> will return <span class="code">Sat Jan 09 2016 16:22:15 GMT+0100 (CET)</span><br> +<pre class="source">${__javaScript(new Date(),MYDATE)}</pre> will return <span class="code">Sat Jan 09 2016 16:22:15 GMT+0100 (CET)</span> and store it under variable <span class="code">MYDATE</span><br> +<pre class="source">${__javaScript(Math.floor(Math.random()*(${maxRandom}+1)),MYRESULT)}</pre> will use maxRandom variable, return a random value between 0 and maxRandom and store it in MYRESULT +<pre class="source">${__javaScript(${minRandom}+Math.floor(Math.random()*(${maxRandom}-${minRandom}+1)),MYRESULT)}</pre> will use <span class="code">maxRandom</span> and <span class="code">minRandom</span> variables, return a random value between <span class="code">maxRandom</span> and <span class="code">minRandom</span> and store it under variable <span class="code">MYRESULT</span> +<pre class="source">${__javaScript("${VAR}"=="abcd",MYRESULT)}</pre> will compare the value of <span class="code">VAR</span> variable with <span class="code">abcd</span>, return <span class="code">true</span> or <span class="code">false</span> and store the result in MYRESULT +</p><div class="go-top"><a href="#">^</a></div></div> -<div class="properties"><h3 id="__Random_parms1"> +<div class="component"><h2 id="__Random">__Random<a class="sectionlink" href="#__Random" title="Link to here">¶</a></h2><div class="description"><p>The random function returns a random number that lies between the given min and max values.</p></div><div class="properties"><h3 id="__Random_parms1"> Parameters <a class="sectionlink" href="#__Random_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">Minimum value</div><div class="description req-true">A number</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-true">Maximum value</div><div class="description req-true">A bigger number</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false">A reference name for reusing the value computed by this function.</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> - -<div class="component"><h2 id="__RandomString">__RandomString<a class="sectionlink" href="#__RandomString" title="Link to here">¶</a></h2> -<div class="description"><p>The RandomString function returns a random String of length using characters in chars to use.</p></div> +</div><p>Examples: +<pre class="source">${__Random(0,10)}</pre> will return a random number between 0 and 10<br> +<pre class="source">${__Random(0,10, MYVAR)}</pre> will return a random number between 0 and 10 and store it in <span class="code">MYVAR</span>. <span class="code">${MYVAR}</span> will contain the random number<br> +</p><div class="go-top"><a href="#">^</a></div></div> -<div class="properties"><h3 id="__RandomString_parms1"> +<div class="component"><h2 id="__RandomString">__RandomString<a class="sectionlink" href="#__RandomString" title="Link to here">¶</a></h2><div class="description"><p>The RandomString function returns a random String of length using characters in chars to use.</p></div><div class="properties"><h3 id="__RandomString_parms1"> Parameters <a class="sectionlink" href="#__RandomString_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">Length</div><div class="description req-true">A number length of generated String</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Characters to use</div><div class="description req-false">Chars used to generate String</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false">A reference name for reusing the value computed by this function.</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> +</div><p>Examples: +<pre class="source">${__RandomString(5)}</pre> will return a random string of 5 characters which can be readable or not<br> +<pre class="source">${__RandomString(10,abcdefg)}</pre> will return a random string of 10 characters picked from <span class="code">abcdefg</span> set, like <span class="code">cdbgdbeebd</span> or <span class="code">adbfeggfad</span>, …<br> +<pre class="source">${__RandomString(6,a12zeczclk, MYVAR)}</pre> will return a random string of 6 characters picked from <span class="code">a12zeczclk</span> set and store the result in <span class="code">MYVAR</span>, <span class="code">MYVAR</span> will contain +string like <span class="code">2z22ak</span> or <span class="code">z11kce</span>, …<br> +</p><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__UUID">__UUID<a class="sectionlink" href="#__UUID" title="Link to here">¶</a></h2> -<div class="description"> +<div class="component"><h2 id="__UUID">__UUID<a class="sectionlink" href="#__UUID" title="Link to here">¶</a></h2><div class="description"> <p>The UUID function returns a pseudo random type 4 Universally Unique IDentifier (UUID).</p> -</div> -<div class="properties"><h3 id="__UUID_parms1"> +</div><div class="properties"><h3 id="__UUID_parms1"> Parameters <a class="sectionlink" href="#__UUID_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> +</div><p>Examples: +<pre class="source">${UUID()}</pre> will return UUIDs with this format : <span class="code">c69e0dd1-ac6b-4f2b-8d59-5d4e8743eecd</span> <br> +</p><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__CSVRead">__CSVRead<a class="sectionlink" href="#__CSVRead" title="Link to here">¶</a></h2> -<div class="description"><p>The CSVRead function returns a string from a CSV file (c.f. <a href="#_StringFromFile">StringFromFile</a>)</p> - <p>NOTE: versions up to 1.9.1 only supported a single file. - JMeter versions since 1.9.1 support multiple file names. +<div class="component"><h2 id="__CSVRead">__CSVRead<a class="sectionlink" href="#__CSVRead" title="Link to here">¶</a></h2><div class="description"><p>The CSVRead function returns a string from a CSV file (c.f. <a href="#_StringFromFile">StringFromFile</a>)</p> + <p>NOTE: JMeter supports multiple file names. </p> <p><b>In most cases, the newer <a href="component_reference.html#CSV_Data_Set_Config">CSV Data Set Config element</a> @@ -622,14 +608,14 @@ the comma after 7 is escaped.</div><div <p> When a filename is first encountered, the file is opened and read into an internal array. If a blank line is detected, this is treated as end of file - this allows - trailing comments to be used (N.B. this feature was introduced in versions after 1.9.1) + trailing comments to be used. </p> <p>All subsequent references to the same file name use the same internal array. N.B. the filename case is significant to the function, even if the OS doesn't care, - so CSVRead(abc.txt,0) and CSVRead(aBc.txt,0) would refer to different internal arrays. + so <span class="code">CSVRead(abc.txt,0)</span> and <span class="code">CSVRead(aBc.txt,0)</span> would refer to different internal arrays. </p> <p> - The *ALIAS feature allows the same file to be opened more than once, + The <span class="code">*ALIAS</span> feature allows the same file to be opened more than once, and also allows for shorter file names. </p> <p> @@ -638,157 +624,128 @@ the comma after 7 is escaped.</div><div the array, so each thread will access a different row from all other threads. [Unless there are more threads than there are rows in the array.] </p> - <p> - Note: the function splits the line at every comma by default. + <div class="clear"></div><div class="note">The function splits the line at every comma by default. If you want to enter columns containing commas, then you will need to change the delimiter to a character that does not appear in any - column data, by setting the property: csvread.delimiter - </p> -</div> - -<div class="properties"><h3 id="__CSVRead_parms1"> + column data, by setting the property: <span class="code">csvread.delimiter</span> + </div><div class="clear"></div> +</div><div class="properties"><h3 id="__CSVRead_parms1"> Parameters <a class="sectionlink" href="#__CSVRead_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> - <div class="property"><div class="name req-true">File Name</div><div class="description req-true">The file (or *ALIAS) to read from</div><div class="required req-true">Yes</div></div> + <div class="property"><div class="name req-true">File Name</div><div class="description req-true">The file (or <span class="code">*ALIAS</span>) to read from</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-true">Column number</div><div class="description req-true"> The column number in the file. - 0 = first column, 1 = second etc. - "next" - go to next line of file. - *ALIAS - open a file and assign it to the alias + <span class="code">0</span> = first column, <span class="code">1</span> = second etc. + "<span class="code">next</span>" - go to next line of file. + <span class="code">*ALIAS</span> - open a file and assign it to the alias </div><div class="required req-true">Yes</div></div> -</div> -<p>For example, you could set up some variables as follows: +</div><p>For example, you could set up some variables as follows: <ul> -<li>COL1a ${__CSVRead(random.txt,0)}</li> -<li>COL2a ${__CSVRead(random.txt,1)}${__CSVRead(random.txt,next)}</li> -<li>COL1b ${__CSVRead(random.txt,0)}</li> -<li>COL2b ${__CSVRead(random.txt,1)}${__CSVRead(random.txt,next)}</li> +<li>COL1a <span class="code">${__CSVRead(random.txt,0)}</span></li> +<li>COL2a <span class="code">${__CSVRead(random.txt,1)}${__CSVRead(random.txt,next)}</span></li> +<li>COL1b <span class="code">${__CSVRead(random.txt,0)}</span></li> +<li>COL2b <span class="code">${__CSVRead(random.txt,1)}${__CSVRead(random.txt,next)}</span></li> </ul> This would read two columns from one line, and two columns from the next available line. If all the variables are defined on the same User Parameters Pre-Processor, then the lines will be consecutive. Otherwise, a different thread may grab the next line. -</p> -<div class="clear"></div><div class="note"> +</p><div class="clear"></div><div class="note"> The function is not suitable for use with large files, as the entire file is stored in memory. For larger files, use <a href="component_reference.html#CSV_Data_Set_Config">CSV Data Set Config element</a> or <a href="#__StringFromFile">StringFromFile</a>. -</div><div class="clear"></div> -<div class="go-top"><a href="#">^</a></div></div> +</div><div class="clear"></div><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__property">__property<a class="sectionlink" href="#__property" title="Link to here">¶</a></h2> -<div class="description"><p>The property function returns the value of a JMeter property. +<div class="component"><h2 id="__property">__property<a class="sectionlink" href="#__property" title="Link to here">¶</a></h2><div class="description"><p>The property function returns the value of a JMeter property. If the property value cannot be found, and no default has been supplied, it returns the property name. When supplying a default value, there is no need to provide a function name - the parameter can be set to null, and it will be ignored. </p>For example:<p> <ul> -<li>${__property(user.dir)} - return value of user.dir</li> -<li>${__property(user.dir,UDIR)} - return value of user.dir and save in UDIR</li> -<li>${__property(abcd,ABCD,atod)} - return value of property abcd (or "atod" if not defined) and save in ABCD</li> -<li>${__property(abcd,,atod)} - return value of property abcd (or "atod" if not defined) but don't save it</li> +<li><span class="code">${__property(user.dir)}</span> - return value of <span class="code">user.dir</span></li> +<li><span class="code">${__property(user.dir,UDIR)}</span> - return value of <span class="code">user.dir</span> and save in <span class="code">UDIR</span></li> +<li><span class="code">${__property(abcd,ABCD,atod)}</span> - return value of property <span class="code">abcd</span> (or "<span class="code">atod</span>" if not defined) and save in <span class="code">ABCD</span></li> +<li><span class="code">${__property(abcd,,atod)}</span> - return value of property <span class="code">abcd</span> (or "<span class="code">atod</span>" if not defined) but don't save it</li> </ul> </p> - </div> - -<div class="properties"><h3 id="__property_parms1"> + </div><div class="properties"><h3 id="__property_parms1"> Parameters <a class="sectionlink" href="#__property_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">Property Name</div><div class="description req-true">The property name to be retrieved.</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Variable Name</div><div class="description req-false">A reference name for reusing the value computed by this function.</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Default Value</div><div class="description req-false">The default value for the property.</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> +</div><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__P">__P<a class="sectionlink" href="#__P" title="Link to here">¶</a></h2> -<div class="description"><p>This is a simplified property function which is +<div class="component"><h2 id="__P">__P<a class="sectionlink" href="#__P" title="Link to here">¶</a></h2><div class="description"><p>This is a simplified property function which is intended for use with properties defined on the command line. - Unlike the __property function, there is no option to save the value in a variable, + Unlike the <span class="code">__property</span> function, there is no option to save the value in a variable, and if no default value is supplied, it is assumed to be 1. The value of 1 was chosen because it is valid for common test variables such as loops, thread count, ramp up etc. </p>For example:<p> <span class="code"> Define the property value: -<br> +<pre class="source"> jmeter -Jgroup1.threads=7 -Jhostname1=www.realhost.edu -<br> +</pre> Fetch the values: <br> -${__P(group1.threads)} - return the value of group1.threads +<span class="code">${__P(group1.threads)}</span> - return the value of <span class="code">group1.threads</span> <br> -${__P(group1.loops)} - return the value of group1.loops +<span class="code">${__P(group1.loops)}</span> - return the value of <span class="code">group1.loops</span> <br> -${__P(hostname,www.dummy.org)} - return value of property hostname or www.dummy.org if not defined +<span class="code">${__P(hostname,www.dummy.org)}</span> - return value of property <span class="code">hostname</span> or <span class="code">www.dummy.org</span> if not defined <br> </span> -In the examples above, the first function call would return 7, -the second would return 1 and the last would return www.dummy.org +In the examples above, the first function call would return <span class="code">7</span>, +the second would return <span class="code">1</span> and the last would return <span class="code">www.dummy.org</span> (unless those properties were defined elsewhere!) </p> - </div> - -<div class="properties"><h3 id="__P_parms1"> + </div><div class="properties"><h3 id="__P_parms1"> Parameters <a class="sectionlink" href="#__P_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">Property Name</div><div class="description req-true">The property name to be retrieved.</div><div class="required req-true">Yes</div></div> <div class="property"><div class="name req-false">Default Value</div><div class="description req-false">The default value for the property. - If omitted, the default is set to "1".</div><div class="required req-false">No</div></div> -</div> -<div class="go-top"><a href="#">^</a></div></div> + If omitted, the default is set to "<span class="code">1</span>".</div><div class="required req-false">No</div></div> +</div><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__log">__log<a class="sectionlink" href="#__log" title="Link to here">¶</a></h2> -<div class="description"> +<div class="component"><h2 id="__log">__log<a class="sectionlink" href="#__log" title="Link to here">¶</a></h2><div class="description"> <p> The log function logs a message, and returns its input string </p> -</div> - -<div class="properties"><h3 id="__log_parms1"> +</div><div class="properties"><h3 id="__log_parms1"> Parameters <a class="sectionlink" href="#__log_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">String to be logged</div><div class="description req-true">A string</div><div class="required req-true">Yes</div></div> - <div class="property"><div class="name req-false">Log Level</div><div class="description req-false">OUT, ERR, DEBUG, INFO (default), WARN or ERROR</div><div class="required req-false">No</div></div> + <div class="property"><div class="name req-false">Log Level</div><div class="description req-false"><span class="code">OUT</span>, <span class="code">ERR</span>, <span class="code">DEBUG</span>, <span class="code">INFO</span> (default), <span class="code">WARN</span> or <span class="code">ERROR</span></div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Throwable text</div><div class="description req-false">If non-empty, creates a Throwable to pass to the logger</div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Comment</div><div class="description req-false">If present, it is displayed in the string. Useful for identifying what is being logged.</div><div class="required req-false">No</div></div> -</div> -<p>The OUT and ERR log level names are used to direct the output to System.out and System.err respectively. +</div><p>The <span class="code">OUT</span> and <span class="code">ERR</span> log level names are used to direct the output to <span class="code">System.out</span> and <span class="code">System.err</span> respectively. In this case, the output is always printed - it does not depend on the current log setting. -</p> -<pre> -For example: - ${__log(Message)} - written to the log file as "...thread Name : Message" - ${__log(Message,OUT)} - written to console window - ${__log(${VAR},,,VAR=)} - written to log file as "...thread Name VAR=value" -</pre> -<div class="go-top"><a href="#">^</a></div></div> +</p><dl> + <dt><span class="code">${__log(Message)}</span></dt><dd>written to the log file as "<span class="code"> … thread Name : Message</span>"</dd> + <dt><span class="code">${__log(Message,OUT)}</span></dt><dd>written to console window</dd> + <dt><span class="code">${__log(${VAR},,,VAR=)}</span></dt><dd>written to log file as "<span class="code"> … thread Name VAR=value</span>"</dd> +</dl><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__logn">__logn<a class="sectionlink" href="#__logn" title="Link to here">¶</a></h2> -<div class="description"> +<div class="component"><h2 id="__logn">__logn<a class="sectionlink" href="#__logn" title="Link to here">¶</a></h2><div class="description"> <p> The logn function logs a message, and returns the empty string </p> -</div> - -<div class="properties"><h3 id="__logn_parms1"> +</div><div class="properties"><h3 id="__logn_parms1"> Parameters <a class="sectionlink" href="#__logn_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div> <div class="property"><div class="name req-true">String to be logged</div><div class="description req-true">A string</div><div class="required req-true">Yes</div></div> - <div class="property"><div class="name req-false">Log Level</div><div class="description req-false">OUT, ERR, DEBUG, INFO (default), WARN or ERROR</div><div class="required req-false">No</div></div> + <div class="property"><div class="name req-false">Log Level</div><div class="description req-false"><span class="code">OUT</span>, <span class="code">ERR</span>, <span class="code">DEBUG</span>, <span class="code">INFO</span> (default), <span class="code">WARN</span> or <span class="code">ERROR</span></div><div class="required req-false">No</div></div> <div class="property"><div class="name req-false">Throwable text</div><div class="description req-false">If non-empty, creates a Throwable to pass to the logger</div><div class="required req-false">No</div></div> -</div> -<p>The OUT and ERR log level names are used to direct the output to System.out and System.err respectively. +</div><p>The <span class="code">OUT</span> and <span class="code">ERR</span> log level names are used to direct the output to <span class="code">System.out</span> and <span class="code">System.err</span> respectively. In this case, the output is always printed - it does not depend on the current log setting. -</p> -<pre> -For example: - ${__logn(VAR1=${VAR1},OUT)} - write the value of the variable to the console window -</pre> -<div class="go-top"><a href="#">^</a></div></div> +</p><dl> + <dt><span class="code">${__logn(VAR1=${VAR1},OUT)}</span></dt><dd>write the value of the variable to the console window</dd> +</dl><div class="go-top"><a href="#">^</a></div></div> -<div class="component"><h2 id="__BeanShell">__BeanShell<a class="sectionlink" href="#__BeanShell" title="Link to here">¶</a></h2> -<div class="description"> +<div class="component"><h2 id="__BeanShell">__BeanShell<a class="sectionlink" href="#__BeanShell" title="Link to here">¶</a></h2><div class="description"> <p> The BeanShell function evaluates the script passed to it, and returns the result. </p> @@ -796,105 +753,93 @@ For example: <b>For full details on using BeanShell, please see the BeanShell web-site at <a href="http://www.beanshell.org/">http://www.beanshell.org/</a> </b> </p> -<p> -Note that a different Interpreter is used for each independent occurence of the function +<div class="clear"></div><div class="note"> +Note that a different Interpreter is used for each independent occurrence of the function in a test script, but the same Interpreter is used for subsequent invocations. This means that variables persist across calls to the function. -</p> +</div><div class="clear"></div> <p> A single instance of a function may be called from multiple threads.
[... 845 lines stripped ...]
