Solved

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

Posted on 2013-02-04
14
631 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 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

20 Experts available now in Live!

Get 1:1 Help Now