Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display only Certain Text

Status
Not open for further replies.
May 13, 2005
3
US
Crystal Reports 11 and DB2 database using the native db2 connection

I have a delimited string that I only need to display a small part of. the string looks something like:
cn=ABC-211,ou=211,ou=home, ou=com | cn=BCD-655, ou=, etc, etc
The only part i need to display is the "ABC-211" and the "BCD-655". The string could have any number of values from 0 to about 8. (to make things worse the delimiter is an unrecognized value, the | is just to represent the delimiter)

I am not much of a programmer but I think I want to start by putting the values into an array, then striping off the cn= and everything after the first comma, then join them back together.

So
instr ({field}, delimiter) > 0 then
split ({field}, delimiter) [] //(how can i put all the values into the array, not just a specified value?)

after that, what is the best way to strip off the junk in the array?

Any help would be greatly appreciated.
 
If I understand your decription, you want the CN vales, and nothng else.

There is no such thing as an unrecognized value, if it were unrecognized, a computer couldn't store it, so discover what it is.

One method is to use the asc("|") to learn it's ascii equivalence.

Once you know that, a formula such as:

whileprintingrecords;
stringvar array MyName:= split(replace(replace("cn=ABC-211,ou=211,ou=home, ou=com | cn=BCD-655","|",",")," ",""),",");
numbervar Counter;
Stringvar Output:="";
if ubound(MyName) > 0 then
(
For Counter := 1 to ubound(MyName) do(
if left(MyName[counter],3) ="cn=" then
Output:=Output+mid(MyName[Counter],4)+ " "
);
);
Output

Should work.

Note that I do a repalce on the pipe symbol here, change that. Also change the MyName to point to your field.

-k
 
Thank you very much for your help. The character turned out to be ACK, I've never come across that as a delimiter before. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top