I have a formula field in my crystal report which is set as "Html Text" in text interpretation. I want to add Line Break So I simply use this
"<br>"&{MyField}
But I want to add Line break dynamically such as it should be aligned according to my field value. For example, if field value is 2 then there will be 2 line breaks or if value is 5 then line breaks will be 5 like this.....
if {LineBreak} = 5 then
"<br><br><br><br><br>"&{MyField}
if {LineBreak} =2 then
"<br><br>"&{MyField}
How can I achieve this?
Use a loop to add <br>s; something like:
Local NumberVar i;
Local StringVar lineBreaks;
lineBreaks := "";
for i := 1 to {LineBreak} do (
lineBreaks := "<br>" & lineBreaks;
);
lineBreaks & {MyField};
instead of HTML you can directly use Chrw(13) in normal formula field.
try below code:
Local Numbervar i;
Local Numbervar j;
Local Stringvar break;
Local Stringvar break1;
for i:=1 to count(databasefield) do
(
break1:="";
for j:=1 to i do
(
if databasefield=i
then break:=break+chrw(13)
);
break1:=break1+break+databasefield;
);
break1;
Related
i want to split data to make it into array. so given for example: 12345678
i want to get string array like this => ["234","678"]
is it possible in crystal report?
Yes, it is possible. But the requirements are not clear.
Data type of input (string or Number?)
Logic: discard 1st character? Then, groups of 3 skipping the 4th character?
Here is formula code that takes "12345678" and returns "^234^678":
local stringvar myString := "12345678";
local stringvar myDelimitedString := "";
local numbervar StringLength := Len(myString);
local numbervar i;
For i := 1 to StringLength step 4 do
myDelimitedString := myDelimitedString + "^" + MID(myString, i+ 1, 3);
myDelimitedString;
I have a field in crystal reports that displays customer's names. the requirement however is to just display the first 5 characters, which includes spacing as well. whatever comes after the 5th character will be converted into * and the spacing shall be displayed as a space still. as the name field varies, how do i accomplish this?
currently i only have this, which displays the first 5 characters and replaces only the 6th character with an *
Replace({Command.CUST_NAME},MID({Command.CUST_NAME},6),"*")
Unfortunately, it seems Crystal does not suport regex.
So, i would do a function. Try this:
stringvar input := {Command.CUST_NAME};
stringvar output := MID(input, 1, 5);
numbervar i;
for i:=5 to Length (input) step 1 do (
stringvar aChar := MID(input, i, 1);
if aChar <> " " then aChar := "*";
output := output + aChar;
);
output
Maybe you will have to handle if {Command.CUST_NAME} is smaller than 5 chars.
I am creating a report by Crystal Reports which will mask address field depending upon parameter set to the report. I know this can be done using formula. I can successfully mask with hard coded value. However I need something like password masking. For example, if address is D/302 ABC apartment, it should be displayed as X/XXX XXX XXXXXXXXX. Only characters and numbers to be masked space and special characters not be masked. In addition length of masked data should match actual data.
I think you can use a formula like this:
Local StringVar str := "";
Local NumberVar strLen := Length({User.Address});
Local NumberVar i;
For i := 1 To strLen Do
(
if (ChrW({User.Address}[i]) in (AscW("A") to AscW("Z"))) or (ChrW({User.Address}[i]) in (AscW("a") to AscW("z"))) or (ChrW({User.Address}[i]) in (AscW("0") to AscW("9"))) Then
str := str + "X"
else
str := str + {User.Address}[i];
);
str
Logic is correct.. I have done the same thing by using Mid function instead of chrW (). No need to use asw () either. Simply use range operator.
Logic is correct.. I have done the same thing by using Mid function instead of chrW (). Additional you can use formula as ReplicateString ("X",len(address));
Only problem is space will be also masked
I am using CR version 13.0.2.000.I want to display the following Record
1,2,5,10,50,100
in the following way
$1
$2
$5
$10
$50
$100
I have tried the replace method and it successfully show the data columnwise but dont know how to append $ sign before the starting of each element
The formula i tried is given below
Replace({Table7.Value},",",chrw(10))
Keep in mind that you won't be able to use a formula to 'manufacture' rows; this will need to be done at the database.
If you just want to change the display, try:
// {#display}
Local Stringvar CRLF := Chr(10)+Chr(13);
// convert values to an array; 1,2,5,10,50,100
Stringvar Array tokens := Split({Table7.Value}, ",");
// join array
"$" + Join( tokens, CRLF + "$");
If you need to tally the array, try:
// {#aggregate}
Local Numbervar i;
Local Numbervar x;
// tally
for i := 1 to ubound(tokens) do (
x := x + ToNumber(tokens[i]);
);
// display
x
Try this solution. I tried by hardcoding strings and its worked for me.
WhilePrintingRecords;
Local StringVar Array x:=split({Table7.Value},",");
Local NumberVar i;
Local Stringvar y;
for i:=1 to Count(x) do
y:=y+"$"+x[i]+",";
Replace(y,",",chrw(13))
I have a number field in Crystal Report that must be shown in a specific format:
Eg:
12345678
must be shown as
1234-5678
I'm using a formula to transform the number to string, substring it 2 times and concatenate both values:
StringVar ordenT := Totext(GroupName ({DataTableInfCR.Orden}));
StringVar OrdenT1 := MID(ordenT,1,4);
StringVar OrdenT2 := MID(ordenT,4,4);
StringVar NroOrden := OrdenT1 +"-"+ OrdenT2;
However, the output for this code ends up being somthing like this:
12.3-45.6
I'm sure it because the default number format is with dots (ex: 12345678 will be 12.345.678)
How can I change the format via formula before my code??
Thanks!
To answer your question, to remove the decimals you use
StringVar ordenT := Totext(GroupName ({DataTableInfCR.Orden}),0);
or
StringVar ordenT := cStr(GroupName ({DataTableInfCR.Orden}),0);
EDIT:
See if this will take care of it all:
totext(GroupName({DataTableInfCR.Orden}),0,""),"xxxx-xxxx")