okneb1
1st September 2016, 12:59
I would like to write a function to seperate random address strings into:
1. street name (A)
2. street number (B)
3. street number prefix/suffix (C)

I'll write down some examples of addresses and what the output should be:

Address 1: "Kastanievej 15"
A -> "Kastanievej"
B -> "15"
C -> ""

Address 2: "Albertinkatu 36 B"
A -> "Albertinkatu"
B -> "36"
C -> "B"

Address 3: "Albertinkatu st. 36/B"
A -> "Albertinkatu"
B -> "36"
C -> "B"

Address 4: "Albertinkatu street A/36"
A -> "Albertinkatu"
B -> "36"
C -> "A"

It gets trickier in England or USA for example, where the notation is "number, street name".

Address 5: "12 Harbour Parade"
A -> "Harbour Parade"
B -> "12"
C -> ""

Also, you can have number in a street name...:
Address 6: "330 W 20th St"
A -> "W 20th St"
B -> "330"
C -> ""

...Or in EU:
Address 6: "Ulica 28. maja 16"
A -> "Ulica 28. maja "
B -> "16"
C -> ""

The code will be something like this:
function split.address(string address, ref street, ref number, ref pre.suff)
{
....

}
My main goal for the moment is to split address strings for EU where
address notation usually is: "street name" "prefix" "housenumber" "sufux"
Any ideas how to approach this in baan C?

mark_h
1st September 2016, 14:15
I am not sure you will get one function to do this unless you know the country. I assume you do - you depending on the country you could call separate functions or one function that checks the country and then uses the appropriate string.scan. There are other ways to do it, but that is probably how I would do it. I know our users did not do it a standard way - they know to fix them as they find them.

benito
1st September 2016, 16:41
you need to build an audit script and might have to run this multiple times until you get it right, or you can run the script by country. for example a single number that can be converted to long goes to B always, or after a string.scan with "/" goes to B always. i hope i'm making sense but this is entirely up to you.