Page 1 of 1
Function - Split Text
Posted: Fri Oct 25, 2019 1:14 am
by brjohnsmith
Hi,
Is there any function that I can use to split text? Ex. TEXT=ABC-123-AABBCC-12AA34BB-BBCCDDEEFF
Considering that I need to separate the text in the example based on the delimiter ˜-˜
Text1=ABC
Text2=123
Text3=AABBCC
Text4=12AA34BB
Text5=BBCCDDEEFF
I know if I use: {Left(TEXT,3)}, I will have = ABC (the text1).
How would be the rest of?
Thank you.
Re: Function - Split Text
Posted: Mon Oct 28, 2019 11:23 am
by Lech Kulikowski
Hello,
You can use the Substring (string str, int startIndex, int length) function
Retrieves a substring from the specified string. The substring starts at a specified character position and has a specified length.
Thank you.
Re: Function - Split Text
Posted: Thu Oct 31, 2019 12:17 am
by brjohnsmith
Hi Lech Kulikowski,
it could work, however, looking at the example, the length is dynamic, and we have the delimiter that is dash, so, besides the substring, I will need also to find the next dash and subtract to the last length in order to get the new length.
des anyone have any idea or some hints?
thank you.
Re: Function - Split Text
Posted: Mon Nov 04, 2019 9:55 pm
by Lech Kulikowski
Hello,
You can add your own function to spit text in the dictionary:
Code: Select all
public class MyFunction
{
private const string Category = "MyFuncCategory";
public static string MyFunc(string value)
{
return value.ToUpper();
}
public static void RegisterFunctions()
{
var ParamNames = new string[1];
var ParamTypes = new Type[1];
var ParamDescriptions = new string[1];
ParamNames[0] = "value";
ParamDescriptions[0] = "Descriptions";
ParamTypes[0] = typeof(string);
Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
}
}