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

Length of a Formula

Status
Not open for further replies.

harrietohs

IS-IT--Management
Apr 26, 2002
99
CA
I just constructed a formula that is 369 lines long Each line is similar to this:

if trim({animal.primary_breed}) = "Golden Retreiver" then "1"

It is used to display a number associated with each of 369 animal breeds. It appears to me that it is working fine, but other Crystal users tell me that is impossible! They say the formula can only be 255 characters long. I do not get an error message when I save the formula.

Can anyone tell me if this long formula should work?

Thanks,

Harriet

 
They are mistaken.

In CR 8.5 or below, you are limited to a length of 254 characters in a field or formula being referenced by a formula.

I would suggest that you create a lookup table in the database for this sort of thing, or consider using the
Select/Case syntax in the future, it's a little less code and a bit more efficient:

select trim({animal.primary_breed})
case "Golden Retreiver": 1
case "Pigbat": 2
...
default :"Unknown"

OK, Pigbat isn't a breed, it's the name of one of my dogs cause he looks like a pig and a bat...

-k
 
I don't have control over the tables in the database; it is a commercial application that uses crystal for report generation. I guess I could do an SQL query and use that as my 'lookup table'. But just so that I am clear, if I did go with the long formula, it should work?

And I love the name "pigbat". Must be a cool dog.

Harriet
 
Yeah, the formula should be fine.

Another somewhat unsavory option would be to create the lookup table in MS Access, or some other database (even a text file), and join that table to the production database table, it's fairly slow, but it lends itself to reuse and maintenance.

-k
 
I suppose I have to ask.....is the formula 369 lines long.....or is the results of the formula 369 lines long

if the results are that long you have a 5 page formula result!!!!!!! in CR 9.0 it may work but [b}WHY!![/b]

the info in that size of a formula should be generated by detail sections.

MY GUESS is that you are confusing the output of a formula with the size of the formula itself.

Even early versions of Crystal allowed large formulas...you were just limited to 254 chars of output.

Jim Broadbent
 
The formula puts out a 1-3 digit code number that matches a specific breed of cat or dog. (There are 369 Breeds) The program I am exporting this data to will accept only those specific codes.
 
Jim: reread the post, she's creating a long formula comprised of a series of IF's (or perhaps now Case's).

-k
 
Synapse,

Have you heard that pets and owners apparently look alike?

[pig][bat]

Hey, it's not my theory so don't go shooting the messenger. [king]


Reebo
Scotland (Sunny with a Smile)
 
In short, yes Crystal (I'm using CR8) will accept a multiple If then else statement of 389 lines. I just tested one with 479 lines


if {PROD} startswith"100"then 1 else
if {PROD} startswith"101"then 2 else
...
if {IIML01.IPROD} startswith"578"then 479
else 999

Mike
 
Reebo: It's nae my dawg, es my wife's, and she will kick yer wee daft punter arse for that, ya ken? ;)

-k
 
SV - I did read the post correctly....SHe is confused about an output of a formula and the construction of a formula.

Output is (CR 9 notwithstanding) limited to 254 chars...the construction of said formula probably has a limit somewhere but 369 lines is not unheard of.

Jim Broadbent
 
Jim: "I just constructed a formula that is 369 lines long Each line is similar to this:"

-k
 
I think we are agreeing here....I do not dispute 369 lines IN a formula...I have written many many formulas greater than that in CR5....

You are not reading my posts carefully

Jim Broadbent
 
OK, I guess *I* misread something.

She stated:

I just constructed a formula that is 369 lines long Each line is similar to this:

If trim({animal.primary_breed}) = "Golden Retreiver" then "1"


You stated:

I suppose I have to ask.....is the formula 369 lines long.....or is the results of the formula 369 lines long

Later you suggest that she is confused here.

Did you think that the output was 369 lines of if statements?

I don't think that she was confused here, but I sorely am ;)

'nuff sed

-k
 
Synapse,

Was that a Welsh accent? By the way, just because I work in scotland, doesn't necessarily mean I'm Scottish.

Reebo
Scotland (Sunny with a Smile)
 
Thanks for the lively threads! I will pass this along to correct the knowledge of those who told me I could not have a formula with 369 "if" statements.

Harriet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top