Print Page | Close Window

Select Text From a String

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20308
Printed Date: 01 May 2024 at 4:00pm


Topic: Select Text From a String
Posted By: MSJM78
Subject: Select Text From a String
Date Posted: 20 Dec 2013 at 1:24pm
Hi my name is Mike I'm new to the Crystal Reports Book Forum.

I have a string field (WOStatusDetail.PartDesc) that contains the following information:

"Grade: Ti 6Al-4V Thickness: 1.750" Width: 6.500" Length: .000" Heat Treat Code: Annealed"

I need to create formulas that create the following, (the length of the text varies):
1) Grade: Ti 6Al-4V
2) Thickness: 1.750"
3) Width: 6.500"
4) Length: .000"
5) Heat Treat Code: Annealed

I have tried MID and INSTR but have failed miserably!
thanks in advance

Mike

-------------
MikeM



Replies:
Posted By: Sastry
Date Posted: 21 Dec 2013 at 8:50pm
Hi

Try this formula: 

stringvar t:='"Grade: Ti 6Al-4V Thickness: 1.750" Width: 6.500" Length: .000" Heat Treat Code: Annealed"';
numbervar a;
numbervar b;
numbervar c;
numbervar d;
numbervar e;
a:=instr(t,'Grade:');
b:=instr(t,'Thickness');
c:=instr(t,'Width:');
d:=instr(t,'Length:');
e:=instr(t,'Heat');
t[a to b-1]&chr(10)&t[b to c-1]&chr(10)&t[c to d-1]&chr(10)&t[d to e-1]&chr(10)&t[e to 200];




-------------
Thanks,
Sastry


Posted By: MSJM78
Date Posted: 23 Dec 2013 at 12:49pm
Thanks Sastry,

The code you provided works great but the field ((WOStatusDetail.PartDesc))has to be separated into the 5 formulas that I stated above. Maybe this can be done with the code you provided but I'm really a newbie and I can't figure out how to do that.

Thanks for your help

-------------
MikeM


Posted By: MSJM78
Date Posted: 23 Dec 2013 at 1:11pm
Never mind Sastry, I slightly modified your code and I got it to work.

thanks a lot for the help!

-------------
MikeM


Posted By: MSJM78
Date Posted: 20 Feb 2014 at 1:14pm
Ok this is a continuation of this topic but with a twist.

Using the code above I get the following results:

High Temp: 1950F / Low Temp: 1760F

Apply Dim: 12 Sqr x 4.6
Pcs: 6

Forge Dim: .800" x 8.900" x 70.000"
Forge Tol: 0.070" x 0.250" x 0.125"

Mults: 4.0

Forging Instructions:
2.500 x 10.00
Reheat 1760F
1.500 x 8.90 x 6

My question: Is there a way to only extract or select the 2 lines of text that begin with:

Forge Dim:
Forge Tol:

Thanks


-------------
MikeM



Print Page | Close Window