Hi,

I have a string which has the full address in it. It also has a comma (,) to
seperate the address into line. I need to be able to read the string and then
split it up at the comma, but ignore passing the comma over. i.e.

I have:

34 Castle Road, Town, County

I need to split it so that i have:

34 Castle Road
Town
County

can someone please let me know the besh way to do this?

Many thanks in advance

Rob

Re: split a string! by Jan

Jan
Fri Feb 03 07:06:54 CST 2006

lnCount = ALINES(laWords, CHRTRAN(lcInputStr, ",", CHR(13)), .T.)

Separated "words" are saved in array laWords containing lnCount rows.
HTH

Robert napsal(a):
> Hi,
>
> I have a string which has the full address in it. It also has a comma (,) to
> seperate the address into line. I need to be able to read the string and then
> split it up at the comma, but ignore passing the comma over. i.e.
>
> I have:
>
> 34 Castle Road, Town, County
>
> I need to split it so that i have:
>
> 34 Castle Road
> Town
> County
>
> can someone please let me know the besh way to do this?
>
> Many thanks in advance
>
> Rob

Re: split a string! by Olaf

Olaf
Sat Feb 04 04:52:31 CST 2006

> lnCount = ALINES(laWords, CHRTRAN(lcInputStr, ",", CHR(13)), .T.)

This works for VFP7 or above:
lnCount = ALINES(laWords, lcInputStr,.T.,",")
No need to change "," to CR.

VFP9 has a new nFlag parameter instead of lTrim,
but still accepts .T. too.

Bye, Olaf.



Re: split a string! by aNOpengellySPAM

aNOpengellySPAM
Mon Feb 06 16:22:14 CST 2006

Hi Rob,

Is this for use in a report? Sorry if I waste your
time up wrong tree.

In reports, I now use a single line text box with
something like:

ocontact.salute, ocontact.firstname,
ocontact.surname; ocontact.add1; ocontact.add2;
ocontact.add3; ocontact.city,
ocontact.postcode;oContact.emailname

all on one line as the field expression and
stretch with overflow checked.

Comes out as

Mr Joe Bloggs
14 Anywhere St
Somewhere
Else SK10 5GH
jbloggs@some_isp.com

The "," will add a space or remove that part and
the semi-colon creates a new line only if there is
anything there

FoxPro seamlessly removes blank spaces and lines -
I got it from Cathy Pountneys book. She says Fox
has been able to do this for years, but it was a
revelation to me (and covered the cost of the book
many times). I use it all the time now for
addresses.

You could maybe use chrtran() to change commas to
semi-colons ...

CHRTRAN("The string, to be searched, goes
here",",",";") ...

regards
Alan

Re: split a string! by Andrew

Andrew
Tue Feb 07 02:06:21 CST 2006

"Alan Pengelly" <aNOpengellySPAM@cix.co.uk> wrote in message
news:memo.20060206222117.1700R@apengelly.compulink.co.uk...
> ocontact.salute, ocontact.firstname,
> ocontact.surname; ocontact.add1; ocontact.add2;
> ocontact.add3; ocontact.city,
> ocontact.postcode;oContact.emailname
>
> all on one line as the field expression and
> stretch with overflow checked.
>
> The "," will add a space or remove that part and
> the semi-colon creates a new line only if there is
> anything there
>
> FoxPro seamlessly removes blank spaces and lines -
> I got it from Cathy Pountneys book. She says Fox
> has been able to do this for years, but it was a
> revelation to me (and covered the cost of the book
> many times). I use it all the time now for
> addresses.

Wow. Yes it works in FPW too, this will be dead useful.

--
Regards
Andrew Howell



Re: split a string! by Jan

Jan
Tue Feb 07 02:50:04 CST 2006

I guess it has worked in FoxBase+ reports too.

Andrew Howell napsal(a):
> "Alan Pengelly" <aNOpengellySPAM@cix.co.uk> wrote in message
> news:memo.20060206222117.1700R@apengelly.compulink.co.uk...
>> ocontact.salute, ocontact.firstname,
>> ocontact.surname; ocontact.add1; ocontact.add2;
>> ocontact.add3; ocontact.city,
>> ocontact.postcode;oContact.emailname
>>
>> all on one line as the field expression and
>> stretch with overflow checked.
>>
>> The "," will add a space or remove that part and
>> the semi-colon creates a new line only if there is
>> anything there
>>
>> FoxPro seamlessly removes blank spaces and lines -
>> I got it from Cathy Pountneys book. She says Fox
>> has been able to do this for years, but it was a
>> revelation to me (and covered the cost of the book
>> many times). I use it all the time now for
>> addresses.
>
> Wow. Yes it works in FPW too, this will be dead useful.
>

Re: split a string! by Fred

Fred
Tue Feb 07 09:17:46 CST 2006

I think this goes all the way back to dBase][.



--
Fred
Microsoft Visual FoxPro MVP


"Jan Bucek" <bucek.jan@post.cz> wrote in message
news:%23uxtrN8KGHA.2392@TK2MSFTNGP09.phx.gbl...
>I guess it has worked in FoxBase+ reports too.
>
> Andrew Howell napsal(a):
>> "Alan Pengelly" <aNOpengellySPAM@cix.co.uk> wrote in message
>> news:memo.20060206222117.1700R@apengelly.compulink.co.uk...
>>> ocontact.salute, ocontact.firstname,
>>> ocontact.surname; ocontact.add1; ocontact.add2;
>>> ocontact.add3; ocontact.city,
>>> ocontact.postcode;oContact.emailname
>>>
>>> all on one line as the field expression and
>>> stretch with overflow checked.
>>>
>>> The "," will add a space or remove that part and
>>> the semi-colon creates a new line only if there is
>>> anything there
>>>
>>> FoxPro seamlessly removes blank spaces and lines -
>>> I got it from Cathy Pountneys book. She says Fox
>>> has been able to do this for years, but it was a
>>> revelation to me (and covered the cost of the book
>>> many times). I use it all the time now for
>>> addresses.
>>
>> Wow. Yes it works in FPW too, this will be dead useful.
>>