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))
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 report with 4 different arrays.
All are set up like this
shared stringvar array arr1 := split({client_relations.sales_value}, "&");
'';
I need them to reset for each group. How do I do that? I tried something like this
WhilePrintingRecords;
shared stringvar array arr1 := " ";
But I got an error saying the formula could not create an array.
Someone suggested to me I try:
WhilePrintingRecords;
shared stringvar array arr1 := "";
'';
And it worked
Create a new formula putting the below code in, calling it reset or something along those lines and place it in the group header.
StringVar Array arr1;
Redim arr1[0];
However, you will have to put any outputs in the group footer for this to work as it resets all data at the start of a new group.
I have a name field that I want to show up as just initials in the report.
So
John Smith
Baba Booey
Jane Doe
Would show up as:
JS
BB
JD
Is there a formula I can run to just show the names?
Just Create a Formula
Try This code
StringVar name_first;
StringVar name_last;
name_first := left({Field_name},1);
name_last := MID({Field_name}, INSTR({Field_name}, " "));
name_first+left(name_last,2);
Hope, This will give you desired results
The ProperCase() function will convert the first letter of each word to uppercase and the rest to lowercase. You can then loop through the converted name and append every capital letter to the result. This should work for any number of first/middle/surnames, and whether the first letter is already capitalized or not:
Local stringVar FullName := ProperCase({FullName_Field});
Local stringVar ResultString := "";
Local numberVar x;
Local stringVar c;
for x := 1 to Length(FullName)
do (
c := mid((FullName), x, 1);
if ascw(c) >= 65 and ascw(c) <= 90 then ResultString := ResultString + c;
);
ResultString;
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;
I've got 2 arrays;
shared stringvar array dkrowarrray;
shared stringvar array newArray;
I know that the first array contains 10 elements.
When I try to set the value of newArray I get a runtime error (Error in formula deltakrow: 'shared stringvar array dkrowarray; ' An array's dimension must be an integer between 1 and 1000). I'm trying to set it like;
numbervar dkrowarraysize := count(dkrowarray);//I also tried ubound here.
redim newArray[dkrowarraysize];
When I prescribe the value like redim newArray[10]; then it runs OK, but the size of the array will need to change.
Why does crystal not like the int variable name between the square brackets?
You misspelled dkrowarrray/dkrowarray. This worked for me:
shared stringvar array dkrowarrray := ["1","2","3","4","5"];
shared stringvar array newArray;
//5
ubound(dkrowarrray);
//0
ubound(newArray);
//3 ('rrr') lower-case 'r' characters in the name
numbervar dkrowarraysize := ubound(dkrowarrray);
//5
redim newArray[dkrowarraysize];
//5
ubound(newArray);