diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs new file mode 100644 index 000000000..f6a09ef66 --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs @@ -0,0 +1,24 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("String Length", "Checks whether the first input is contained in the second input.", + "Text", InputType = typeof(string), OutputType = typeof(Numeric))] +public class StringLengthNode : Node +{ + public StringLengthNode() + : base("String Length", "Returns string length.") + { + Input1 = CreateInputPin(); + Result = CreateOutputPin(); + } + + public InputPin Input1 { get; } + + public OutputPin Result { get; } + + public override void Evaluate() + { + Result.Value = new Numeric((Input1.Value ?? "").Length); + } +} \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs new file mode 100644 index 000000000..7dd6b1d0b --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs @@ -0,0 +1,29 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("String Null or WhiteSpace", "Checks whether the string is null or white space.", + "Text", InputType = typeof(string), OutputType = typeof(bool))] +public class StringNullOrWhiteSpaceNode : Node +{ + public StringNullOrWhiteSpaceNode() + : base("Null or White Space", "Returns true if null or white space") + { + Input1 = CreateInputPin(); + TrueResult = CreateOutputPin("true (Empty)"); + FalseResult = CreateOutputPin("false (Not Empty)"); + } + + public InputPin Input1 { get; } + + public OutputPin TrueResult { get; } + + public OutputPin FalseResult { get; } + + public override void Evaluate() + { + bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value); + TrueResult.Value = isNullOrWhiteSpace; + FalseResult.Value = !isNullOrWhiteSpace; + } +} \ No newline at end of file