Page 1 of 1
Subfield Function
Posted: Thu Nov 01, 2012 7:29 pm
by tims
Is there a SubField function, or a way to create one in Stimulsoft.
I have a delimited list and I need to select the Nth value to display.
I've seen a function in other report engines in which you specify a string, a field number, and a delimter, and it returns the appropriate string.
For example:
SubField("AAA|BBB|CCC|DDD|EEE|FFF",3,"|") returns CCC
SubField("AAA;BBB;CCC;DDD;EEE;FFF",5,";") returns EEE
If there was no delimiter, it would return the whole string.
Re: Subfield Function
Posted: Fri Nov 02, 2012 6:00 am
by Alex K.
Hello,
Unfortunately, but this function is not available on our product.
As a way, you can add it manually in designer on Code tab and then use it.
Thank you.
Re: Subfield Function
Posted: Mon Nov 05, 2012 3:32 pm
by tims
Can you provide the code required to create this function?
Re: Subfield Function
Posted: Tue Nov 06, 2012 10:10 am
by Alex K.
Hello,
You can add the following function:
Code: Select all
public string SubField(string s, char delimeter, int index)
{
return s.Split(new char[] { delimeter })[index - 1];
}
and use the following expression:
Thank you.
Re: Subfield Function
Posted: Wed Dec 19, 2012 9:22 pm
by tims
Thank you for the response. The formula itself is working correctly.
I need to have the field inex increment with the page number. The formula is located on in a Child Data band, with a filter to only show certain values. When I type in a number as the index, it works fine. When I use PageNumber as the index, it does not use the filter, and it shows the wrong values.
https://dl.dropbox.com/u/99199395/SubField%20Issue.PNG
I created 2 Child Databands, the one at the top right shows when using pagenumber as the index. the lower values are showing correctly for an index of 1, which is how the formula is hard coded.
Data and report in the zip below.
https://dl.dropbox.com/u/99199395/Micro ... kOrder.zip
Re: Subfield Function
Posted: Thu Dec 20, 2012 2:13 pm
by HighAley
Hello.
Sorry, we need more time to prepare an answer for you.
Thank you.
Re: Subfield Function
Posted: Fri Dec 21, 2012 8:53 am
by Alex K.
Hello,
For correct result you can use the additional variable instead the ""PageNumber". And increment this variable in BeforePrint event of DataBand1 component.
Thank you.