Substring

From UBot Studio
Jump to: navigation, search

$Substring is a Text Function.

The function returns the specified part of an original string.

The substring begins at a given starting point and extends up to the given length. Again, this function can be used the way that the other functions can be used, except this finds the determined subtext of a string.

The function can be used along with the Text Length and Find Index functions to determine the substring of an item in a string.

The text length function finds the length of the substring in the place in the substring function labeled "Number of Characters".

The find index function finds the starting point for the substring being searched for within the original text.

Original Text: The original text the substring will be pulled from. Accepts variables and functions such as $next list item, $list item, $random list item, $previous list item, and $table cell.

Starting Point: The starting point of the substring within the original text.

Number of Characters: The length of the substring.


Example 1

navigate("http://www.ubotstudio.com/playground/simple-form", "Wait")
type text(<username field>, $substring("UBot Studio", $find index("UBot Studio", "Studio"), $text length("Studio")), "Standard")

Running the script fills the field with the substring at the starting point and with the number of characters specified in the substring function. In this case the substring is the word "Studio".


Sbstrg9.jpg

Example 2

Avoid a using the alert command at all. Only pull 10 characters from the user's input to stay within requirements for a website:

ui text box("mytext", #mytext)
if($comparison($text length(#mytext), ">", 10)) {
then {
alert($substring(#mytext, 0, 10))
}
else {
alert(#mytext)
}
}


If the user inputs text longer than 10 characters, the script will only pull 10 characters from the input.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox