Replace function not working in Crystal Reports
Oh, you're going to be mad about this one :)
The Replace() function is being evaluated... but each time you're overwriting the variables stk and tst with only a single replacement of the original strings, tstnummer and stknummer. When all the Replaces() are done, you're simply left with a string with no white space character. Need to change to this...
...
tst := Replace (tst,":" ,"_" );
tst := Replace (tst,"." ,"_" );
tst := Replace (tst,"=" ,"_" );
...
stk := Replace (stk,":" ,"_" );
stk := Replace (stk,"." ,"_" );
jorrebor
Updated on June 04, 2022Comments
-
jorrebor almost 2 years
when i provide string stknummer = "*VU-NR:-93.10xxxxxxxx_2-12-2011*" to this function:
whileprintingrecords; shared stringvar tstnummer; shared stringvar stknummer; local stringvar tst; local stringvar stk; local stringvar bc; tst := tstnummer; stk := stknummer; //why is this not evaluated? tst := Replace (tstnummer,":" ,"_" ); tst := Replace (tstnummer,"." ,"_" ); tst := Replace (tstnummer,"=" ,"_" ); tst := Replace (tstnummer,"/" ,"_" ); tst := Replace (tstnummer,"\" ,"_" ); tst := Replace (tstnummer,"?" ,"_" ); tst := Replace (tstnummer,"#" ,"_" ); tst := Replace (tstnummer,"." ,"_" ); tst := Replace (tstnummer,"*" ,"_" ); tst := Replace (tstnummer,"|" ,"_" ); tst := Replace (tstnummer,"<" ,"_" ); tst := Replace (tstnummer,">" ,"_" ); tst := Replace (tstnummer," " ,"-" ); //and this neither? stk := Replace (stknummer,":" ,"_" ); stk := Replace (stknummer,"." ,"_" ); stk := Replace (stknummer,"=" ,"_" ); stk := Replace (stknummer,"/" ,"_" ); stk := Replace (stknummer,"\" ,"_" ); stk := Replace (stknummer,"?" ,"_" ); stk := Replace (stknummer,"#" ,"_" ); stk := Replace (stknummer,"." ,"_" ); stk := Replace (stknummer,"*" ,"_" ); stk := Replace (stknummer,"|" ,"_" ); stk := Replace (stknummer,"<" ,"_" ); stk := Replace (stknummer,">" ,"_" ); stk := Replace (stknummer," " ,"-" ); //select file output format if {?barcode_type} = true then (if trim(stk) ="" then bc:= "*" + tst + "_" + totext(dateValue({@signdate})) + "*" else ( bc:= "*" + stk + "_" + totext(dateValue({@signdate})) + "*");;) else bc := "*" + tst + "_" + totext(dateValue({@signdate})) + "*"
The result is that no replacements are made (i.e. the : is still there)
when i put Replace(stk, ":", "_") in the bottom function like:
//select file output format if {?barcode_type} = true then (if trim(stk) ="" then bc:= "*" + tst + "_" + totext(dateValue({@signdate})) + "*" else ( bc:= "*" + Replace (stk, ":", "_") + "_" + totext(dateValue({@signdate})) + "*");;) else bc := "*" + tst + "_" + totext(dateValue({@signdate})) + "*"
The replacement is done correctly.
Why are the replacements not done in the first example?
I good put all replacements in the function but that not all too elegant....
THanks