Length
The Length node is a utility node that calculates the length of a given string input. It is commonly used in text processing and validation workflows to determine the number of characters in a string.Inputs
a(string, default: ""): The input string to calculate the length of.
Outputs
result(integer): The length of the input string.
Configuration
This node does not have any configuration options.Usage
- Connect a node that provides a string output to the
ainput of the Length node. - The Length node will calculate the number of characters in the input string.
- The
resultoutput will contain the length of the input string as an integer value. - Connect the
resultoutput to other nodes that require the string length for further processing or validation.
Example
Here’s an example of how to use the Length node in a spell:- The
data/input/stringnode provides the input string “Hello, World!”. - The
logic/length/stringnode calculates the length of the input string. - The
data/output/numbernode outputs the length of the string, which is 13.
Best Practices
- Use the Length node when you need to determine the number of characters in a string for validation, formatting, or further processing.
- Connect the Length node to a string input source, such as a
data/input/stringnode or the output of another node that provides a string value. - Use the
resultoutput of the Length node to pass the string length to other nodes that require this information.
Common Issues
- Ensure that the input connected to the
ainput of the Length node is a valid string. Connecting a non-string value may result in unexpected behavior or errors. - Keep in mind that the Length node counts all characters in the string, including whitespace characters like spaces, tabs, and newline characters.
