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

Urgent help on seperating a string onto new lines!

Status
Not open for further replies.

edove

Programmer
Nov 5, 2001
48
GB
I am reporting off a Notes database, with Crystal Reports 8.5.

One of the fields returns an address, each line of the address is seperated by a semi colon. Does anyone know the functions required to seperate the address, so that each line, is displayed on a new line.
So instead of 80 Headstone Road; York; HGF6 6TT, you see
80 Headstone Road;
York;
HGF6 6TT

This is urgent, thanks a lot in advance!
 
Hi,

You need to use some sort of formula which will replace all semi-colons by chr(13)+chr(10)

This will generate a carriage_return/linefeed between each line of the address.

For loops are available in 8.5 so you should be able to do it using that.

Hth,
Geoff


 
Use teh funtion Split("textfield",";") This will split the text field into however many components are separated by a semicolon ";" or any other separater. You will have to use an array to actually extract the values. For example, given the formula:

split("abc;def;ghj",";")

formulaname[2] will return "def" Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Yeah I tried using the Slip function, but it just kept saying something about 'the result could not be an array'.
 
try this, just replace my string with your database field:

WhileReadingRecords;
stringVar array Address:= split("abd;def;ghi;jkl",";");
Address[1]

This will return the first value of the string array called Address, which is "abd". Create a 2nd, 3rd, 4th, 5th...etc formula to get the remaining pieces of the string, up to the maximum number you would expect for the report.

Let me know if you have any questions:
Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Hi,

{@Addr_formula}
stringvar s1 := {addr_field}
numbervar p1 := instr(s1,";")
if p1 > 0 then
s1 := left(s1,p1-1) + chr(13)+chr(10) + mid(s1,p1+1)
p1 := instr(s1,";")
if p1 > 0 then
s1 := left(s1,p1-1) + chr(13)+chr(10) + mid(s1,p1+1)
p1 := instr(s1,";");
if p1 > 0 then
s1 := left(s1,p1-1) + chr(13)+chr(10) + mid(s1,p1+1)
p1 := instr(s1,";")
if p1 > 0 then
s1 := left(s1,p1-1) + chr(13)+chr(10) + mid(s1,p1+1)
p1 := instr(s1,";")
if p1 > 0 then
s1 := left(s1,p1-1) + chr(13)+chr(10) + mid(s1,p1+1)
p1 := instr(s1,";")
if p1 > 0 then
s1 := left(s1,p1-1) + chr(13)+chr(10) + mid(s1,p1+1)
s1


This will cater for any address string with upto 7 address lines.

Geoff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top