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

Crystal version 11

Status
Not open for further replies.

jveglia

MIS
Mar 26, 2001
13
US
I am using crystal 11 and have a field in the database that is a string field and contains multiple data elements.
For ex: 10.25;0;0;4.5;0

The field contains freight and shipping charges each seperated by a ;. I need to parse the field and create 5 fields from it. I tried the spit command and unsuccessful. Any help is greatly appreaciated.

john
 
There may be an easier way but this works, you will need to build a series of formula similar to these, replace the hardcoded string '10.25;0;0;4.5;0' with your field.

@Str1 End
instr('10.25;0;0;4.5;0', ';')-1

@str1
mid('10.25;0;0;4.5;0', 1,{@Str1 End})

@Str2 End
instr(instr('10.25;0;0;4.5;0', ';')+1, '10.25;0;0;4.5;0', ';')

@str2
mid('10.25;0;0;4.5;0', {@Str1 End}+2, {@Str2 End}-{@Str1 End}-2)

using the same logic build formulae for string 3 and 4

You can also use clever Do While loops to determine positions of the ; and then break down field into 4 Stringvars, but that would be even more complex.

Ian

 
Using split should work. Create five separate formulas, with this format:

//{@firstelement}:
stringvar array x := split({table.field},";");
if ubound(x) >= 1 then
x[1] else
{table.field}

//{@secondelement}:
stringvar array x := split({table.field},";");
if ubound(x) >= 2 then
x[2]

//etc.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top