View previous topic :: View next topic
|
Author |
Message |
hernikiten
New User
Joined: 08 Apr 2005 Posts: 23 Location: india
|
|
|
|
Hi,
I have a name variable with any characters (for eg mr. subhash agarwal, mRs. sheila STAGE. etc.). I have to convert this string so that it shows correct format ( eg. Mr. Subhash Agarwal, Mrs. Sheila Stage.
please suggest the "inspect syntax" for this, also if there's an alternative.
Thanks. |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
Really need more information about your name fields
ie
field size
are the ONLY possibilities Mr and Mrs?
is there always a period after the Mr/Mrs?
does the Forename always start in the same position?
does the Surname always start in the same position
Is it possible that there are middle names, double names
anything else that you are not telling us? |
|
Back to top |
|
|
hernikiten
New User
Joined: 08 Apr 2005 Posts: 23 Location: india
|
|
|
|
Good day IQ,
The positions might change depending upon length of first and middle name. Mr. and Mrs. are the only possibilities.
Thanks |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
I think I would use a combination of INSPECT and UNSTRING
along the following lines
first convert all of your name field to lower case
ie
INSPECT NAME-FIELD
CONVERTING
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' TO
'abcdefghijklmnopqrstuvwxyz'
Next split your field into three, I am assuming that there is always a space between title and firstname and firstname and surname and that there are no middle names.
thus set up three fileds to hold the data eg
01 TITLE.
03 TITLE1 Pic x
03 TITLEX Pic x(3)
FIRSTNAME (same as TITLE but you determine size)
SURNAME (same as TITLE but you determine size)
so
UNSTRING NAME-FIELD DELIMITED BY ALL SPACES INTO
TITLE
FIRSTNAME
SURNAME
now you have three fields all lower case so all you need to do now is set the first character in each to upper case eg
Move 'M' to TITLE1
INSPECT FIRSTNAME1
CONVERTING
”abcdefghijklmnopqrstuvwxyz “TO
”ABCDEFGHIJKLMNOPQRSTUVWXYZ “
INSPECT SURNAME1
CONVERTING
”abcdefghijklmnopqrstuvwxyz “TO
”ABCDEFGHIJKLMNOPQRSTUVWXYZ “
then you might want to STRING or MOVE the data back into the original format but I will leave that to you |
|
Back to top |
|
|
|