Return

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Additional Information)
(Example 1)
 
(One intermediate revision by one user not shown)
Line 9: Line 9:
  
  
== Example ==
+
== Example 1 ==
 
<pre>
 
<pre>
 
+
navigate("http://ubotstudio.com/playground/simple-form", "Wait")
 
define $my test function {
 
define $my test function {
 
     set(#test, $eval($add(5, 2)), "Global")
 
     set(#test, $eval($add(5, 2)), "Global")
Line 17: Line 17:
 
}
 
}
 
type text(<about me textarea>, $my test function(), "Standard")
 
type text(<about me textarea>, $my test function(), "Standard")
 +
  
 
</pre>
 
</pre>
Line 26: Line 27:
  
 
[[File:return.jpg]]
 
[[File:return.jpg]]
 
  
 
== Additional Information ==
 
== Additional Information ==

Latest revision as of 17:01, 7 September 2014

This command is a Flow Command. This command exits the current command or function and allows custom functions to return a value.

This command is designed to allow the user to re-use code in the form of custom functions where a value is returned.

This command is used within the define command.


Return Value: the value that is being returned from the custom functions.


[edit] Example 1

navigate("http://ubotstudio.com/playground/simple-form", "Wait")
define $my test function {
    set(#test, $eval($add(5, 2)), "Global")
    return(#test)
}
type text(<about me textarea>, $my test function(), "Standard")



Running the above script creates a function that calculates 5+2 in the variable "test". The return command sets the entire function to the value of the calculation in the variable. The function is then used to place the result in the specified field.


Return.jpg

[edit] Additional Information

Did you know that you can break a loop within a define command with a return command?

You can place the loop in a define, and the return command will break the loop, exit out of the define command and run the script that comes after the define command.

define blue {
    loop(1) {
        alert("Hi!")
        return(0)
        alert("Howdy Partner!")
    }
}
blue()
alert("Hello There!")


The following example will run the alert that displays the greeting "Hi!"

Because of the return command, the script will exit the define command and run the command after that, which is an alert that displays the greeting "Hello There!".

Return0.jpg

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox