Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Select Text From a String Post Reply Post New Topic
Author Message
MSJM78
Newbie
Newbie
Avatar

Joined: 03 Dec 2013
Online Status: Offline
Posts: 4
Quote MSJM78 Replybullet Topic: Select Text From a String
    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
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet 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
IP IP Logged
MSJM78
Newbie
Newbie
Avatar

Joined: 03 Dec 2013
Online Status: Offline
Posts: 4
Quote MSJM78 Replybullet 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
IP IP Logged
MSJM78
Newbie
Newbie
Avatar

Joined: 03 Dec 2013
Online Status: Offline
Posts: 4
Quote MSJM78 Replybullet 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
IP IP Logged
MSJM78
Newbie
Newbie
Avatar

Joined: 03 Dec 2013
Online Status: Offline
Posts: 4
Quote MSJM78 Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.