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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split string field 1

Status
Not open for further replies.

ecsrs

Technical User
Apr 22, 2002
35
0
0
US
I have a string field that I need to split if it is over 30 characters long. I would like to split it inbetween words. How would I write a formula that would split the string at the space before 30 characters. For example: "Please help me with this problem" I would need to split this string between "this" and "problem" because it is the space before 30 characters. I hope I have explained this clearly. I have a limited amount of space on my report for this field and want to put one string in the detaila section and the rest in the detailb section of the report.
 
Posting your Crystal version might help with the supplied solution as there are different approaches.

Here's a string version:

whileprintingrecords;
stringvar array OutputArray:=split({table.field}, " ");
stringvar Output1:="";
stringvar Output2:="";
numbervar counter;
For Counter := 1 to ubound(OutputArray) do(
if len(Output)+len(OutputArray[Counter]) <= 30 then
Output1:=Output1+OutputArray[Counter]+" "
else
Output2:=Output2+OutputArray[Counter]+" "
);

Now you can display these by referencing the 2 variables elsewhere, as in:


whileprintingrecords;
stringvar Output1

or

whileprintingrecords;
stringvar Output1

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top