Field splitting

Printed From: Crystal Reports Book — Forum Name: Talk with the Author

Hello.  I'm having an issue regarding a comma delimited field, and would appreciate any help that you can provide.
 
I have a single field (call it Field X) that can have up to 26 different 4-character ids in it, each separated by a comma.  As an example:
 
Record 1 could have Field X=INCM,CASH,LIQU,DECB
Record 2 could have Field X=CASH,INCM,BALA,TERM
etc.etc.
 
What I need to do is take Field X, and incorporate their true, literal descriptions.  I.E., INCM means "Income Insufficient".  CASH means "Cashflow Insufficient", etc, etc.
 
So for Record 1 as an example, I need to take Field X=INCM,CASH,LIQU,DECB, and convert the 4 ids into:
"Income Insufficient,Cashflow Insufficient,Liquidation,Derogatory Business Credit".
 
However, because I can have anywhere from zero to 26 different possibilities, and those 26 possibilities can be in any kind of order, I'm trying to find the easiest way to "switch" the 4-character id for the true description.
 
I've played around with Switch and/or Choose and I can't get anything to work.  If anyone has any suggestions, I'd appreciate it!  Thanks, Mike
I would try using the Mid function. If that doesnt work, try split.

How many total codes do you have? You could do a formula something like this:

stringvar descrips := {table.code field};
descrips := replace(descrips, "INCM", "Income Insufficient");
descrips := replace(descrips, "CASH", "Cash Insufficient");
...<go through all of your possible codes>...
descrips
 
The final line is important.  DO NOT put a semi-colon (;) at the end of it.  Put this formula on your report instead of the field.  If you're in Crystal XI, this should be no problem.  If you're in (I believe) any earlier version, there is a 250 character limit  for strings.
 
-Dell
Thank you!  That worked perfectly!