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

Array Split

Status
Not open for further replies.

socalvelo

Technical User
Jan 29, 2006
128
US
CR11 Oracle db

I would like to create a parameter and place it in the record selection allowing a person to choose a street name.

{location.field} has a standardized pattern of street addresses, but there are a few variations because of breaks in the street name.

Here are a couple examples:

1011 W 52ND ST
1652 S DEL MONTE AV
324 E MAIN ST

I want to extract only the street name, by allowing a startswith{?Street} record seleciton.

52ND
DEL MONTE
MAIN


This would be very easy for me if there were no two element street names. The street name will always start in the third element. The problem is a street name that contains more than one word.

Creating a formula such as the one below, gives me the third element:

stringvar array x := split({GAPD_INMAST_VIEW.Location}," ");
x[3];

How do I add the fourth element. I realize that most of the street names will contain ("AV". "ST", etc in the fourth element) but this shouldn't be a problem since I will use a startwith command with the parameter, and most of the actual street name will be selected for the records.

I don't fully understand the use of "ubound" and I am puzzled on how to add that fourth element.
 
Can you just test for the 4th element

stringvar array x := split({GAPD_INMAST_VIEW.Location}," ");

If not(x[4] in ['ST', 'AV']) then x[3]&" "&x[4] else
x[3]

Ian;


 
You can use UBOUND to find the number of table elements. Work from there, e.g.
Code:
if if ubound(split({your.field}," ")) = 3 
then split({your.field}," ")[3]
else
if if ubound(split({your.field},":")) = 4 
then split({your.field}," ")[3] & " " 
   & split({your.field}," ")[4]
That's assuming that there are always either 3 or 4 elements. You could include checks for others, maybe reporting as invalid.





[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top