Text Length
From UBot Studio
(Difference between revisions)
(One intermediate revision by one user not shown) | |||
Line 7: | Line 7: | ||
'''Text:''' The text where the text length will be pulled from. Accepts variables and functions such as [[$next list item]], [[$list item]], [[$random list item]], [[$previous list item]], and [[$table cell]] under Text to Type. | '''Text:''' The text where the text length will be pulled from. Accepts variables and functions such as [[$next list item]], [[$list item]], [[$random list item]], [[$previous list item]], and [[$table cell]] under Text to Type. | ||
− | == Example == | + | == Example 1 == |
<pre> | <pre> | ||
set(#text length, $text length("mytext"), "Global") | set(#text length, $text length("mytext"), "Global") | ||
Line 13: | Line 13: | ||
− | [[File: | + | [[File:txtlngth.jpg]] |
Running the script sets the variable to the total text length of the string. | Running the script sets the variable to the total text length of the string. | ||
+ | |||
+ | |||
+ | == Example 2 == | ||
+ | |||
+ | Use the text length function to limit the amount of characters required for a field. | ||
+ | |||
+ | For example: | ||
+ | |||
+ | <pre> | ||
+ | ui text box("mytext", #mytext) | ||
+ | if($comparison($text length(#mytext), ">", 10)) { | ||
+ | then { | ||
+ | alert("Please enter 10 characters or less") | ||
+ | } | ||
+ | else { | ||
+ | navigate("google.com", "Wait") | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | The following example will generate am alert to the end user if the length of the provided text in the UI is longer than required. |
Latest revision as of 22:04, 28 December 2016
$Text Length is a Text Function.
The function returns the total length of string.
Please see Pad Text for more examples.
Text: The text where the text length will be pulled from. Accepts variables and functions such as $next list item, $list item, $random list item, $previous list item, and $table cell under Text to Type.
[edit] Example 1
set(#text length, $text length("mytext"), "Global")
Running the script sets the variable to the total text length of the string.
[edit] Example 2
Use the text length function to limit the amount of characters required for a field.
For example:
ui text box("mytext", #mytext) if($comparison($text length(#mytext), ">", 10)) { then { alert("Please enter 10 characters or less") } else { navigate("google.com", "Wait") } }
The following example will generate am alert to the end user if the length of the provided text in the UI is longer than required.