Cut string wit String Tempalte

Hello guys!

I want to cut string if lenght this string is > 100.

So i created some String Template, but it does not work.

StringCutting.v4p (4.1 KB)

#region usings
using System;
using System.ComponentModel.Composition;

using VVVV.PluginInterfaces.V1;
using VVVV.PluginInterfaces.V2;
using VVVV.Utils.VColor;
using VVVV.Utils.VMath;

using VVVV.Core.Logging;
#endregion usings

namespace VVVV.Nodes
{
	#region PluginInfo
	[PluginInfo(Name = "StringCut", Category = "String")]
	#endregion PluginInfo
	public class StringStringCutNode : IPluginEvaluate
	{
		#region fields & pins
		[Input("Input", DefaultString = "hello c#")]
		public ISpread<string> FInput;

		[Output("Output")]
		public ISpread<string> FOutput;

		[Import()]
		public ILogger FLogger;
		#endregion fields & pins

		//called when data for any output pin is requested
		public void Evaluate(int SpreadMax)
		{
			FOutput.SliceCount = SpreadMax;

			for (int i = 0; i < SpreadMax; i++)
            	{	
            		if (FOutput[i].Length >100)
            		    {
              	  			FOutput[i] = FInput[i].Substring(0,100);
              	  		}
              		else 
              	  		{
              	  			FOutput[i] = FInput[i];
              	  		}
              	}
		}
	}
}

Sorry need to change )))))))))))

if (FOutput[i].Length>100)

to

if (FInput[i].Length >100)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.