Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 646
  • Last Modified:

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

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
ArrowheadConsulting
Asked:
ArrowheadConsulting
  • 7
  • 4
  • 2
  • +1
1 Solution
 
peter57rCommented:
All works here OK.

Can you show us a sample value for {@reportsize}
0
 
mlmccCommented:
Where do you see the value?

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

Is that the entire formula?

mlmcc
0
 
ArrowheadConsultingAuthor Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ArrowheadConsultingAuthor Commented:
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
 
peter57rCommented:
Add a new first line to your formula field...

EvaluateAfter ({@ReportSize});

Try it again.
0
 
ArrowheadConsultingAuthor Commented:
Same result. No change. For example:
Round Tubing: 2-3/16x0-10/16x12-12/16
0
 
ArrowheadConsultingAuthor Commented:
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
 
peter57rCommented:
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
 
ArrowheadConsultingAuthor Commented:
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
 
peter57rCommented:
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
 
ArrowheadConsultingAuthor Commented:
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
 
mlmccCommented:
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
 
James0628Commented:
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
 
ArrowheadConsultingAuthor Commented:
Apparently what I was doing was correct. No real explanation why it failed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now