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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a simple function 1

Status
Not open for further replies.

dancarr22

Programmer
Oct 15, 2002
8
0
0
CA
I have several fields in my result set that are 0 or 1. 0 is 'Pass', 1 is 'Fail'
I would like to create a function that accepts one IN parameter (the 1 or 0) and returns a string 'PASS' or 'FAIL'.
I know I can do this for every field individually (i.e. If {test1.field1}=0 then 'Pass' else 'Fail'
But, would rather have a generic reusable function.
Any assistance greatly appreciated.

thanks,
Dan
 
What version of Crystal are you using?

BTW, I think that your function would still have to reference a different field, so the gain seems minimal.

Here's an example using CR 9:


CR 8.5 or below require a UFL, which means using VB or some external code to create a loadable function, which probably isn't very cost effective for such a simple task.

One cheat you might use is to create a generic formula:

whileprintingrecords;
booleanvar TrueFalse := {table.booleanvar}
If TrueFalse = 0 then 'Pass' else 'Fail'

Now you can change the {table.Booleanvar} for each formula.

Again, for such a simple task, you aren't buying much.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top