Subfield Function

Stimulsoft Reports.NET discussion
Post Reply
tims
Posts: 41
Joined: Thu Mar 26, 2009 9:40 am
Location: Canada

Subfield Function

Post 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.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Subfield Function

Post 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.
tims
Posts: 41
Joined: Thu Mar 26, 2009 9:40 am
Location: Canada

Re: Subfield Function

Post by tims »

Can you provide the code required to create this function?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Subfield Function

Post 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:

Code: Select all

{SubField(v2, '|', 3)}
Thank you.
tims
Posts: 41
Joined: Thu Mar 26, 2009 9:40 am
Location: Canada

Re: Subfield Function

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Subfield Function

Post by HighAley »

Hello.

Sorry, we need more time to prepare an answer for you.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Subfield Function

Post 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.
Attachments
Label no Factory1.mrt
(70.8 KiB) Downloaded 180 times
Capture.PNG
Capture.PNG (52.71 KiB) Viewed 1845 times
Post Reply