cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find "Crystal Type" code examples?

Former Member
0 Kudos

Morning all,

I have tried searching the forums but cant find much (I dont find the search thread function very helpful but that might just be me and is another story for another time).

I am trying to create my own formulars and functions on my report in CR4E, but I am have problems with the code.

Where can I find a tutorial on the basics like converting a date to a string or delcaring a date or changing a string to a date.

In Java one would do something like:


String str_MyString;

str_MyString = "This is a string";

but in a crystal report you do something like (and I might incorrect in even this simple example):


StringVar str_MyString;

str_MyString = "This is a string";

That slight difference of String and StringVar are the things I need to find out.

In VB I can refer to a forms fields with str_MString = me.txt_Field1 but in crystal I dont know how to refer to a current field of the report I am working with.

For example, I have a text box on my report which I have called "txt_MyNumber", I then want a formular or function to use the value that is found in that text box but cant work out to refer to it. I can refer to other formulars but not report fields. Is this even possible?

I know the report field question might be viewed as a whole new question thus thread but I feel they close enough to remain in the same thread.

So any help pointing me in the right direction.

Or am I just an idiot and should rather give up trying to design crystal reports. (Ive been thrown in the very deep end at work so am trying to work everything out all at once with no beginner knowledge)

Thanks all for help and suggestions.

Cheers

Darren

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you intend to create a Java User-Defined Function Libraries you can refer to the following link:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/JRC_SDK/jrc_java_dg_doc/doc/jrcsd...

For more about the U FL api reference you can refer to this link:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/JRC_SDK/jrc_udfl_api_doc/doc/jrcs...

Cheers

Former Member
0 Kudos

Thanks for the quick reply, Alphonse

Creating a UFL is what brought me to realise I am lacking in knowledge in the first place.

I created a UFL that converts numbers to words. I am going to be using this later for translating

transaction amounts into words in different languages.

As a test I created a simple resource bundle that held 1=one, 2=two and so on until 10.

My function is

get_numbers_to_words(String key, String resBundleName, String str_Locale)

So to test it I created a formula on in my report and used the following bit of code to test it.


str_Number_to_Words  //formula name
get_number_in_words("1", "NumbertoWords", ContentLocale)

This works and gives me a return of "one".

So I then wanted to have a field on the report pass in the key. The field is called txt_Number, so i tried:


str_Number_to_Words  //formula name
get_number_in_words({txt_Number}, "NumbertoWords", ContentLocale)

but clearly that did not work. I tried many other variables or ways of putting the value I hold in the

txt_Number field.

I have no way of using the value held by the text box txt_Number.

I then thought if I cant get a field to drive the key I will use something as simple as taking the current time

and use the seconds unit digit as the variable to dynamically change and gives more a better testing

ground so when I expand to the double figures I can use the seconds in general.

This is what made me put up this post.

With your first link you sent me, I am ashamed to say I dont really know how best to take that knowledge

and put it in practice. This is where my lack of knowledge shines through. I understand what most

methods and classes do from their descriptions and summaries and all that. But I am trying I promise.

All I need is for one example to be shown and explained how the concept gets taken from those Package

descriptions and into a working example I will be able to then work out how to use it for all the rest.

Take com.crystaldecisions.reports.common.value.DateValue for example.

If this last request is a silly request and a real waste of everyones time I totally understand and will start

looking other ways of learning this all. I will not hold it against anyone if they tell me to go back to "school"

and leave programming to real men/women.

Thanks Alphonse and also the rest fo you.

Cheers

New Edited part:

OK I am sort of getting somewhere. I have now got a function that can return the current time as a string

but the part to return only the seconds is not working.


Minutes_To_Number    //Function Name
Function (TimeVar curr_Time)
StringVar str_Minute;
str_Minute = CStr(Second(curr_Time));  // This does not seem to be returning the current seconds. Why?
//str_Minute = CStr(curr_Time);  //If this is not commented out I get the current time, so I know its working
str_Minute;

Var_Number      //Formular name
Minutes_To_Number(PrintTime)

str_Number_to_Words   // Formular that I want to get working
// I want to pass the seconds into the Key field of my UFL function.
get_number_in_words({@Var_Number}, "NumbertoWords", ContentLocale)

Any ideas why the

Second(curr_Time)

does not return the seconds value?

Edited by: Darren Jackson on Sep 19, 2008 3:36 PM

_________________-

Ok I have managed to work out why my code was failing.

It all boiled down to my use of "=" and not ":=". This being the type of Syntax differences I need to learn. Well guess I will just have to go through all the Example reports (found them after asking).

So Im going to close this thread as worked out the answers.

Cheers

Edited by: Darren Jackson on Sep 22, 2008 2:43 PM

Answers (0)