Eval
(→Example) |
|||
(17 intermediate revisions by one user not shown) | |||
Line 2: | Line 2: | ||
$Eval is a [[Math Functions|Math Function]]. | $Eval is a [[Math Functions|Math Function]]. | ||
+ | '''A javascript enabled website must be open in the main browser in order for the eval function to run. | ||
− | == Example == | + | A blank browser will return blank results.''' |
+ | |||
+ | '''Expression:''' the math or javascript expression being evaluated. | ||
+ | |||
+ | Please keep in mind that the maximum number that a 32 bit integer can be is 2,147,483,647. | ||
+ | |||
+ | For example, this calculation will result in a number that is greater than the maximum number: | ||
+ | |||
+ | <pre> | ||
+ | alert($multiply(1162261467,2)) | ||
+ | </pre> | ||
+ | |||
+ | The result is a negative number. | ||
+ | |||
+ | Please keep that in mind when processing calculation with the eval command. | ||
+ | |||
+ | |||
+ | == Example 1: Math Expressions == | ||
<pre> | <pre> | ||
Line 9: | Line 27: | ||
type text(<about me textarea>, $eval($add(4, 4)), "Standard") | type text(<about me textarea>, $eval($add(4, 4)), "Standard") | ||
</pre> | </pre> | ||
+ | |||
+ | |||
Typing 4+4 into the eval function brings up a new function called the add function. | Typing 4+4 into the eval function brings up a new function called the add function. | ||
+ | |||
<pre> | <pre> | ||
$eval($add(4, 4)) | $eval($add(4, 4)) | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | [[File:eval.jpg]] | ||
+ | |||
+ | |||
+ | <pre>navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") | ||
+ | type text(<about me textarea>, $eval($subtract(4, 4)), "Standard") | ||
+ | </pre> | ||
+ | |||
The subtract function appears when 4-5 is typed into the eval function. | The subtract function appears when 4-5 is typed into the eval function. | ||
+ | |||
<pre> | <pre> | ||
Line 27: | Line 58: | ||
Running the script will fill the field with the correct answer for 4-4. | Running the script will fill the field with the correct answer for 4-4. | ||
− | [[File: | + | |
+ | [[File:eval0.jpg]] | ||
+ | |||
+ | |||
+ | |||
+ | == Example 2: Running Javascript == | ||
+ | |||
+ | Eval can also be used to run javascript. | ||
+ | |||
+ | In this example, the function runs a piece of javascript that returns set cookies from a website and sets the cookies to a variable. | ||
+ | The cookies are also displayed in full in an alert window. | ||
+ | |||
+ | <pre> | ||
+ | ui text box("Website URL:", #website) | ||
+ | navigate(#website, "Wait") | ||
+ | wait(2) | ||
+ | set(#blue, $eval("document.cookie"), "Global") | ||
+ | alert($eval("document.cookie")) | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | Type in a url to see what cookies the set command and the alert returns. |
Latest revision as of 16:20, 7 December 2016
This function returns the results of executing a piece of javascript or simple mathematical equations. $Eval is a Math Function.
A javascript enabled website must be open in the main browser in order for the eval function to run.
A blank browser will return blank results.
Expression: the math or javascript expression being evaluated.
Please keep in mind that the maximum number that a 32 bit integer can be is 2,147,483,647.
For example, this calculation will result in a number that is greater than the maximum number:
alert($multiply(1162261467,2))
The result is a negative number.
Please keep that in mind when processing calculation with the eval command.
[edit] Example 1: Math Expressions
navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") type text(<about me textarea>, $eval($add(4, 4)), "Standard")
Typing 4+4 into the eval function brings up a new function called the add function.
$eval($add(4, 4))
navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") type text(<about me textarea>, $eval($subtract(4, 4)), "Standard")
The subtract function appears when 4-5 is typed into the eval function.
$eval($subtract(4, 4))
Going back to our original script:
Running the script will fill the field with the correct answer for 4-4.
[edit] Example 2: Running Javascript
Eval can also be used to run javascript.
In this example, the function runs a piece of javascript that returns set cookies from a website and sets the cookies to a variable. The cookies are also displayed in full in an alert window.
ui text box("Website URL:", #website) navigate(#website, "Wait") wait(2) set(#blue, $eval("document.cookie"), "Global") alert($eval("document.cookie"))
Type in a url to see what cookies the set command and the alert returns.