Solved

Crystal Reports Multi-line Replace Fails - only last line executed

Posted on 2013-02-04
14
632 Views
Last Modified: 2013-02-09
I have a formula that creates a long string with fractions in sixteenths. I want to replace, for example, 2/16 with 1/8 and 4/16 with 1/4, etc.

My original Formula is @ReportSize
My new formula which I use to display the size string is @ReportSizeFrac which is shown below. It seems that only the last line is working. None of the others are working. I still see 5-8/16 instead of 5-1/2.


Local StringVar HoldString;
HoldString :=replace({@ReportSize},"-0/16","");
HoldString :=replace(HoldString,"-2/16","-1/8");
HoldString :=replace(HoldString,"-4/16","-1/4");
HoldString :=replace(HoldString,"-6/16","-3/8");
HoldString :=replace(HoldString,"-8/16","-1/2");
HoldString :=replace(HoldString,"-10/16","-5/8");
HoldString :=replace(HoldString,"-12/16","-3/4");
HoldString :=replace(HoldString,"-14/16","-7/8");
HoldString :=replace(HoldString,"x0-","x");
HoldString :=replace(HoldString,".00","");
0
Comment
Question by:ArrowheadConsulting
  • 7
  • 4
  • 2
  • +1
14 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38853052
All works here OK.

Can you show us a sample value for {@reportsize}
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38853473
Where do you see the value?

Did you put the formula with the replaces on the report?

Is that the entire formula?

mlmcc
0
 

Author Comment

by:ArrowheadConsulting
ID: 38853768
Here is what is currently getting printed:

Angle L1:2-0/16 L2:2-0/16x0-4/16x8-4/16

What it should print is:

Angle L1: 2 L2: 2 x1/4x8-1/4

The -0/16 should be replaced by null string
The -4/16 should be replaced by -1/4

If you look at the attached .PDF, the column labeled "Size" contains the values of @ReportSizeFrac
sample.pdf
0
 

Author Comment

by:ArrowheadConsulting
ID: 38853787
If it helps, here is the formula for @PageSize:

select {Fab_Item.SteelType}
case  "Plate": "Plate:"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16x"&{Fab_Item.sz_width_in}&"-"&{Fab_Item.sz_width_16}&"/16x"&{Fab_Item.sz_thickness_in}&"-"&{Fab_Item.sz_thickness_16}&"/16"
case  "Pipe": "Pipe: "&{Fab_Item.sz_width_in}&"x"&{Fab_Item.sz_thickness_in}&"x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
case  "Beam": "Beam: "&{Fab_Item.size_in}&"x"&{Fab_Item.sz_width_in}&"x"&{Fab_Item.sz_thickness_in}&"x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
case  "Channel": "Channel: "&{Fab_Item.size_in}&"x"&{Fab_Item.sz_width_in}&"x"&{Fab_Item.sz_thickness_in}&"x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
case "Rect": "Rect. Tube: "&{Fab_Item.size_in}&"x"&{Fab_Item.sz_width_in}&"x"&{Fab_Item.sz_thickness_in}&"x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
case "Rod": "Rod: "&{Fab_Item.sz_width_in}&"-"&{Fab_Item.sz_width_16}&"/16x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
case "Round": "Round Tubing: "&{Fab_Item.sz_thickness_in}&"-"&{Fab_Item.sz_thickness_16}&"/16x"&{Fab_Item.sz_width_in}&"-"&{Fab_Item.sz_width_16}&"/16x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
case "Angle": "Angle L1:"&{Fab_Item.size_in}&"-"&{Fab_Item.size_16}&"/16 L2:"&{Fab_Item.sz_width_in}&"-"&{Fab_Item.sz_width_16}&"/16x"&{Fab_Item.sz_thickness_in}&"-"&{Fab_Item.sz_thickness_16}&"/16x"&{Fab_Item.sz_lth_in}&"-"&{Fab_Item.sz_lth_16}&"/16"
default: ""
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38854063
Add a new first line to your formula field...

EvaluateAfter ({@ReportSize});

Try it again.
0
 

Author Comment

by:ArrowheadConsulting
ID: 38855347
Same result. No change. For example:
Round Tubing: 2-3/16x0-10/16x12-12/16
0
 

Author Comment

by:ArrowheadConsulting
ID: 38855491
To prove to myself that only the final Replace works, I copied the line:
HoldString :=replace(HoldString,"-12/16","-3/4");

to the bottom. Now I get:
Round Tubing: 2-3/16x0-10/16x12-3/4

Only the replacement of 12/16 by 3/4 is working now.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 77

Expert Comment

by:peter57r
ID: 38855558
All I can say then is that when I put these original values as variables in your formula I get correct results.

I have used this for testing various values and get correct results every time.

Local StringVar HoldString;
//Holdstring:="12-0/16, 4-2/16,7-3/16,123-6/16,245-7/16,23-8/16,32-9/16,42-10/16";
//Holdstring:= "Plate:19-0/16x3-8/16x0-4/16";
Holdstring:="Angle L1:2-0/16 L2:2-0/16x0-4/16x8-4/16";

HoldString :=replace(holdstring,"-0/16","");
HoldString :=replace(HoldString,"-2/16","-1/8");
HoldString :=replace(HoldString,"-4/16","-1/4");
HoldString :=replace(HoldString,"-6/16","-3/8");
HoldString :=replace(HoldString,"-8/16","-1/2");
HoldString :=replace(HoldString,"-10/16","-5/8");
HoldString :=replace(HoldString,"-12/16","-3/4");
HoldString :=replace(HoldString,"-14/16","-7/8");
HoldString :=replace(HoldString,"x0-","x");
HoldString :=replace(HoldString,".00","");
Holdstring
0
 

Author Comment

by:ArrowheadConsulting
ID: 38855589
Interesting, I copied the line:
HoldString :=replace(HoldString,"-10/16","-5/8");

to the bottom and now I get:
Round Tubing: 2-3/16x0-5/8x12-3/4

Now the last 2 replaces are working.

I kept going until I copied everything. Now everything is working! Here is what I ended up with. Can someone explain what is going on????

EvaluateAfter ({@ReportSize});
Local StringVar HoldString;
HoldString :=replace({@ReportSize},"-0/16","");
HoldString :=replace(HoldString,"-2/16","-1/8");
HoldString :=replace(HoldString,"-4/16","-1/4");
HoldString :=replace(HoldString,"-6/16","-3/8");
HoldString :=replace(HoldString,"-8/16","-1/2");
HoldString :=replace(HoldString,"-10/16","-5/8");
HoldString :=replace(HoldString,"-12/16","-3/4");
HoldString :=replace(HoldString,"-14/16","-7/8");
HoldString :=replace(HoldString,"x0-","x");
HoldString :=replace(HoldString,".00","");
HoldString :=replace(HoldString,"-12/16","-3/4");
HoldString :=replace(HoldString,"-10/16","-5/8");
HoldString :=replace(HoldString,"-14/16","-7/8");
HoldString :=replace(HoldString,"-8/16","-1/2");
HoldString :=replace(HoldString,"-6/16","-3/8");
HoldString :=replace(HoldString,"-4/16","-1/4");
HoldString :=replace(HoldString,"-2/16","-1/8");
HoldString :=replace(HoldString,"-0/16","");
HoldString :=replace(HoldString,"x0-","x");
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 38855640
I can't explain that.

It looks like some sort of corruption in the formula field.  But you should now be able to delete the original lines and be good to go.
0
 

Author Comment

by:ArrowheadConsulting
ID: 38855712
This is what I get now. (see sample).

It looks like everything is working -- but I really don't know what I did to fix it.
sample2.pdf
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38858010
I wonder if some of the - were not really - but one of the other characters that look like it.  I recall that issue from a question here.

mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 38858858
mlmcc has a point.  That has come up here before where someone had used the wrong character.  But if I copy&paste the formula from your first post into CR, it works fine (I replace {@ReportSize} with the example string you posted later).  So, if you did a copy&paste from CR into your first post, then the characters in CR were probably fine.  I guess maybe if you pasted the formula into something else first and then copied it from there to here, that something else might have "translated" some characters into the "normal" ones.

 James
0
 

Author Closing Comment

by:ArrowheadConsulting
ID: 38871701
Apparently what I was doing was correct. No real explanation why it failed.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now