Return

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
Line 26: Line 26:
  
 
[[File:return.jpg]]
 
[[File:return.jpg]]
 +
 +
 +
== 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.
 +
 +
<pre>
 +
define blue {
 +
    loop(1) {
 +
        alert("Hi!")
 +
        return(0)
 +
        alert("Howdy Partner!")
 +
    }
 +
}
 +
blue()
 +
alert("Hello There!")
 +
 +
</pre>
 +
 +
 +
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!".

Revision as of 14:47, 12 November 2013

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.


Example


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


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!".

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox