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!

display words separately from String 1

Status
Not open for further replies.

neskin

Programmer
Mar 13, 2002
104
AU
i have a field address1 : street,suburb,postcode,country.
All of the words separeted by comma
need to dysplay
street
suburb,postcode,country
if one of them is missing (suburb,,country) then
the comma not be dysplayed
I have started with that and stuck
NumberVar FirstReturn := InStr ({ADDRESS1},",");
NumberVar SecondReturn := InStr (FirstReturn+1,{ADDRESS1},",");
NumberVar ThirdReturn := InStr (SecondReturn+1,{ADDRESS1},",");
NumberVar ForthReturn := InStr (ThirdReturn+1,{ADDRESS1},",");
StringVar Street := "";
StringVar Suburb := "";
StringVar Postcode := "";
StringVar Country := "";
NumberVar End :=0;

if FirstReturn > 0 then
Street := Left ({ADDRESS1},FirstReturn-1);
if SecondReturn > 0 then
Suburb := Mid ({ADDRESS1},FirstReturn+1);
if ThirdReturn > 0 then
End := ThirdReturn - SecondReturn;
if ThirdReturn <= 0 then
End := Length ({ADDRESS1});

Postcode := Mid ({ADDRESS1},ForthReturn+1);

Street & CHR(13)+ Suburb + Postcode

can I have a hand to finish this of
thanks
Nat
 
it took me a while, but this will work:

Code:
stringvar array myString;
stringvar output;
numbervar i;

myString := split({ADDRESS1},",");
for i:=1 To UBound(myString) do
(
    if myString[i] <> "" then
        output := output & myString[i] & ", "
);
output[1 to -3];

To run a test of how this works without using that field try
Code:
stringvar array myString;
stringvar output;
numbervar i;

myString := split("street,,zip,city",",");
for i:=1 To UBound(myString) do
(
    if myString[i] <> "" then
        output := output & myString[i] & ", "
);
output[1 to -3];
 
thank you for the code i have tested and it is showing all previous addresses as well in one string.(record1address ok then for record2 showing record1address and record2 address and so on ) I need for each record.
Example :string in db
Private Bag 92007,Auckland 1020,,New Zealand
need to display
Private Bag 92007 -- one line then
Auckland 1020,New Zealand --second line

Thanks again
Nat

 
Set the output to an empty string when declaring it and it should work

Code:
stringvar array myString;
stringvar output:="";
numbervar i;

myString := split({ADDRESS1},",");
for i:=1 To UBound(myString) do
(
    if myString[i] <> "" then
        output := output & myString[i] & ", "
);
output[1 to -3];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top