diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs new file mode 100644 index 000000000..421ad4dec --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs @@ -0,0 +1,24 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("Text Length", "Outputs the length of the input text.", + "Text", InputType = typeof(string), OutputType = typeof(Numeric))] +public class StringLengthNode : Node +{ + public StringLengthNode() + : base("Text Length", "Outputs text length.") + { + Input1 = CreateInputPin(); + Result = CreateOutputPin(); + } + + public InputPin Input1 { get; } + + public OutputPin Result { get; } + + public override void Evaluate() + { + Result.Value = Input1.Value == null ? new Numeric(0) : new Numeric(Input1.Value.Length); + } +} \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs new file mode 100644 index 000000000..6c80e372f --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs @@ -0,0 +1,25 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("Text is empty", "Outputs true if the input text is empty, false if it contains any text.", + "Text", InputType = typeof(string), OutputType = typeof(bool))] +public class StringNullOrEmptyNode : Node +{ + public StringNullOrEmptyNode() + : base("Text is empty", "Outputs true if empty") + { + Input1 = CreateInputPin(); + Output1 = CreateOutputPin(); + } + + public InputPin Input1 { get; } + + public OutputPin Output1 { get; } + + public override void Evaluate() + { + bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value); + Output1.Value = isNullOrWhiteSpace; + } +} \ No newline at end of file