JS_Execute Function

Description:

This function compiles and executes a javascript script. On successful completion, the strOutput or floatOutput variable holds the value from the last executed expression statement processed in the script.

Format:

result = js_execute(script);
result = js_execute(script, strOutput);
result = js_execute(script, floatOutput);

Parameter:

script

A charcater string containing the script to compile and execute

strOutput

Receives the value of the last-executed expression statement processed in the script. An error occurs if the last-executed expression is not a character string expression

floatOutput

Receives the value of the last-executed expression statement processed in the script. An error occurs if the last-executed expression is not a float expression

Example:

String strOutput;
float floatOutput;

js_execute("function Add(i,j) {return i+j;}");

js_execute("Add(12.1,23.2);", floatOutput);
log "result is: " + tostring(floatOutput);

js_execute("Add(\"Hello \",\"World\");", strOutput);
log "result is: " + strOutput;

js_execute("concatStr=Add(\"Good \",\"Morning\");");
js_execute("concatStr;",strOutput);
log "result is: " + strOutput;
 

Output:

result is: 35.3
result is: Hello World
result is: Good Morning





Go back to the Learning center:


Copyright © AgileLoad. All rights reserved.
Agile Load testing tool| Contact AgileLoad | Terms of Use | Sitemap