This is a migrated thread and some comments may be shown as answers.

substr

2 Answers 719 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kmv
Top achievements
Rank 1
kmv asked on 24 Jun 2008, 10:28 PM
if i use substr to simply show the first 20 chars of an address, =substr(Address,20) its fine as long as the address is longer than 20 chars and isnt null, but delivers errors if the address is either short or null

2 Answers, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 25 Jun 2008, 08:17 AM
Hello Kevin,

The current implementation of Substr() built-in function is based on System.String.Substring() method without performing any additional validation of the input data, which happens to be the problem in your case. I have logged this issue in our bug tracking system and it will be fixed in the next version scheduled for the end of July. We have updated your Telerik Points.

Fortunately you can use your own custom substring function, where you can handle all the exceptional situations and prevent any errors. For more information on the user defined functions, please see Using Expressions.

All the best,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Scott
Top achievements
Rank 1
answered on 25 Jun 2008, 02:25 PM
I'm not sure this is a bug. Trying to substring 20 chars off a 5 char string is an error.

Regardless, this might be a simpler work-around:

=substr(Address+"                    ",20)
Tags
General Discussions
Asked by
kmv
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Scott
Top achievements
Rank 1
Share this question
or