Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function language in Crystal: Crystal or Basic

Status
Not open for further replies.

majordog

Programmer
Jul 8, 2002
222
CA
Hi,
I just wanted to verify what language exactly Crystal is referring to when it refernces 'Basic'. If I wrote a function in Visual Basic code would it be transferrable to Crystal? I suppose this must seem particularily dense - but better to ask a stupid question then not know. Thanks in advance for any responses!
S
 
OK, I know that Basic is not Visual basic but that they ARE similar. Also, I discovered that if you can program in either C++ or Visual Basic you can make an URL otherwise know as a DDL and create function available to your reports in those languages. Now, I am looking for a "How To.." site. Does anyone know of a good one or have the time to write out what I need to do to set this up? Also, you've probably reached this deduction on your own, I want to display a field onmy report that will have to pass other data from same report through some calculations(whicxh will exist in the functions), the result being the value displayed - In what can I display the value in? I assumed a text field but is this wrong?
 
That's a UFL, aka DLL.

Basic is the alternative language to Crystal syntax for use with creating formulas within Crystal Reports, this is different from a UFL.

UFL's are external functions designed to extend the capabilities of CR.

And CR 9 has reusable user defined functions.

If you truly need a UFL, check out:


Perhaps if you shared the intent, someone here can describe how to approach the problem in an efficient manner.

-k kai@informeddatadecisions.com
 
Yes, you are right, I meant UFL. I am currently working with Crystal 8.5. The report that I am currently working on has a sub report which supplies Temperature, Pressure and Relative Humidity. In order to calculate the KH I have to pass the values of these three fields into a function which will perform the calculation and return the value for KH. I need to display the KH value on the sub-report. The report looks like:

Test Results:

Dist Temp Pressure Rel Humid KH DF SCF
Bag 1 -5.97 100.89 80.53 .78 22.03 6487
3.00
Bag 2 -6.62 100.87 76.18 .78 38.05 11071
3.80
Bag 3 -6.01 100.85 76.09 .78 28.25 6475
2.94

I have created this sub-reoprt up the point of all the fields except the calculated ones, which are the KH and DF.
The Temp, Pressure, Rel Humidity will have to be assigned to a variable which get passed to a function called...let's say, 'Function getkhvalue(pressure AS Single, temp AS single, relHumid AS single)' The body of the calculation(written in VB for now):
**********************************************************
Dim ra, pb, pd, h, kh AS single

ra = relhumid
pb = pressure * 7.501

pd = steam(temp)
h = (43.478 * ra * pd)/ pb - (pd * (ra/100.00)))
kh = 1.00/(1.00 - 0.0047 * (h - 75.00))

getkhvalue = kh
**********************************************************
The Function steam looks like (in VB as well):
Function steam(inval As single) As Single
steam = (0.0000045992 * inval ^ 4 + 0.00009034 * inval ^ 3 +
0.012783 * inval ^ 2 + 0.31761 * inval + 4.6085)
**********************************************************
It was my understanding that you could extend the functionality of crystal by including a UFL which IS a DDL. If there is a way to do the above without having to go through the effort of creating a DDL, then I would be quite pleased to discover this. This calculation is actually the easiest on this report and the next sub-report will require some heavy looping and conditional statements, etc....At any rate if you have some ideas on how I can achieve this, I would be very interested. Thanks in advance.
SE
 
In answer to my own question, I created function fields and broke down the formula so I could put single pieces into their own function fields. The final piece of the code in the function field @KH was visible and the others were not. This allowed me to perform the calculation.
 
Synapsevampire,
I know this is an old post but I have an additional question on that link you provided for UFL creation. I have finally made the conclusion that the calculations required for this report are too complex to be placed in the report. I need to use a UFL if I want to be able to do what needs to be done. I followed your link, which was great. After following the steps, and creating a .dll, I was not able to see it from Crystal. The 'How To..' sheets are so straightforward that I don't think I missed something. At any rate I have verified everything several times. I have been looking for additional information to troubleshoot this. Are you able to help me?
S
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top