BBC BASIC for Windows
« Splitting up complex names »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:10pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Splitting up complex names  (Read 914 times)
hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
xx Splitting up complex names
« Thread started on: Apr 3rd, 2016, 06:11am »

Hi All,

Is there a way to split up a name into separate strings when the name may contain more than 2 elements?

I know how to deal with 2 elements, such as John Smith, for example:-

rem Separate names into first and last
input "Enter the full name ";FullName$
Posn% = instr(FullName$, " ")
FirstName$ = left$(FullName$, Posn%-1)
Surname$ = mid$(FullName$, Posn%+1)
print "Your first name is ";FirstName$
print "Your surname is ";Surname$
end

But how would you handle names like:-
John van Smith
John van de Burgh
John Paul Bob Smith Jr.

Thanks to anyone who has had the same issue before and solved it.

Regards,

John
User IP Logged

Ian Kings
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 3
xx Re: Splitting up complex names
« Reply #1 on: Apr 3rd, 2016, 10:20am »

John,

You can use Richards split function available in the STRINGLIB.

Here's a short example.

Code:
      REM FN_split(A$, d$, RETURN a$())
      REM
      REM Split a string at specified delimiter:
      REM A$ is the string to be split
      REM d$ is the delimiter at which to split
      REM a$() is an array to receive the parts (created if necessary)
      REM The returned value is the number of array elements written

      INSTALL @lib$+"STRINGLIB"

      fullname$="John Paul Smith"
      result=FN_split(fullname$, " ", parts$())

      FOR i=0 TO result-1
        PRINT parts$(i)
      NEXT i

      END

 


Ian
User IP Logged

hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
xx Re: Splitting up complex names
« Reply #2 on: Apr 3rd, 2016, 8:18pm »

Hi Ian,

Thank you.

That's worked great!

Appreciate your help.

Regards,
John.
User IP Logged

JGHarston
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 52
xx Re: Splitting up complex names
« Reply #3 on: Apr 10th, 2016, 3:00pm »

on Apr 3rd, 2016, 06:11am, hinckleyj wrote:
Is there a way to split up a name into separate strings when the name may contain more than 2 elements?
...
But how would you handle names like:-
John van Smith
John van de Burgh
John Paul Bob Smith Jr.

Some of that requires human interaction, or a degree of artificial intelligence. For example, how does a program know which part of "John van de Burgh" is the surname? Is he Mr Burgh, first name John, middle names van de? With that example you can program in that components with a lower-case initial letter are part of the surname, but then you get Mao Ze Dung. Is he Mr Dung or Mr Ze Dung?

I've written programs that parse Census records and spit out regular data fields. When the source has had the entire name in one field I parse it backwards looking for the first space, or the last space followed by a lower case letter.

Viz:
Elizabeth Anderson Gibbons
Elizabeth Anderson#Gibbons
Jacob Henley-Stamp
Jacob#Henley-Stamp
Mikael van der Holdt
Mikael#van der Holdt
Pietor von Tasman von Beringburg
Pietor von Tasman#von Beringburg

Though it still needs outside knowledge added to it to cope with:
David Lloyd George
David#Lloyd George
User IP Logged

hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
xx Re: Splitting up complex names
« Reply #4 on: Apr 10th, 2016, 8:39pm »

on Apr 10th, 2016, 3:00pm, JGHarston wrote:
I've written programs that parse Census records and spit out regular data fields.


Would you be willing to share those here?

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls