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

split: the result of a formula cannot be an array

Status
Not open for further replies.

JeroenBoon

Technical User
Aug 15, 2002
106
NL
Hello,

when I want to use the split function in CR8.5, I get the message "the result of a formula cannot be an array", even when I copy and paste the example from the helpsection into my report. What am I doing wrong?

Thanks, Jeroen.
 
What exactly do you want to use the function for? I'm guessing it delimits the string using the delimiter specified and creates an array of the results. You would be able to cycle through the array to output the results, but what do you actually want to do?
 
@ Katy44:

I want to split an article description into pieces. As the splitter I want to use the /. So for instance:
"Table / 120 cm / white" would have to result in "Table" and "120 cm" and "white".

Jeroen.
 
But would the result be a string? if so, you probably want some function to replace '/' with ' ' (I think there's a 'replace' fn, but could be wrong). If it's an array you want, you would have to do something with it.
What do you want acrually displayed on the report?
 
There is a replace function:

Code:
Replace (inputString, findString, replaceString)
 
Depending on how you want to display the fields on the report, you might need three formulas - one for each piece:

//@Piece1
Split({Table.Field},"/")[1];

//@Piece2
Split({Table.Field},"/")[2];

//@Piece3
Split({Table.Field},"/")[3];

-dave
 
would this work for a number ? if I have n costs in a grouped field from a table - can I get the split to push each one out individually - and then multiply them by a datediff?
 
You should post example data and expected output, this is turning into a blog because of your one sentence posts. And what did you try?

Here's an example of using a number.

Would this work for a number...

If the data is stored with a delimiter, then it isn't a number. You can make a number out of it, keying off of Dave's example:

//@Piece1
val(Split({Table.Field},"/")[1];)

Would return the frist value as a number, meaning that you could use it in calcs.

Posting basic inforamtion up front will quickly result in a solution, one sentence blurbs will result in a torturously long process for everyone.

Crystal version
Database/connectivity used
Example data
Expected output

Pretty basic, but it explains more concisely than a text description might.

-k
 
I've got a database field that contains "City,State,Zip" (comma-delimited), so I tried using this approach:

//@Facility
WhilePrintingRecords;
stringvar FacCity := split({DBTABLE.LOCFIELD},",")[1];
stringvar FacState := split({DBTABLE.LOCFIELD},",")[2];
stringvar FacZip := split({DBTABLE.LOCFIELD},",")[3];

I then created three formulas that look like this one:

//@FacCity
WhilePrintingRecords;
stringvar FacCity;
FacCity;

I created another one for FacState & FacZip, and used these three in my report. Once I put them to use, I started getting Invalid Index errors.

Has anyone seen this before, and if so, what's causing this error?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top