Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stripping
Message
From
09/04/2008 13:00:26
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01309362
Message ID:
01309432
Views:
9
Maybe so, but it works great and I'm good with that for now.

>I believe right now you're overcomplicating things. Checking each word in the name against the list of Prefixes, Suffixes, etc. seems like much easier solution.
>
>E.g.
>lcFinalName = ""
>for lnI = 1 to getwordcount(tcName)
>   Grab the word, check against the string with suffixes/prefixes
>   if matches, we would not use this word in the Final name
>   else
>    we would use this name
>    lcFinalName = lcFinalName + word
>  endif
>next
>
>
>>I only had to tweak a couple things and it worked great. Thanks!
>>
>>>>>First, do not use CHRTRAN() use STRTRAN():
>>>>>
>>>>>m.ReplaceWith = ''
>>>>>m.PrefixSearchString = [ MR MRS MS MISS DR PROF SIR MASTER REV REVERAND ETC ]
>>>>>FOR x = 1 TO GETWORDCOUNT( m.PrefixSearchString )
>>>>>    m.LookFor = [ ]+ALLTRIM(UPPER(GETWORDNUM(m.PrefixSearchString,x)))+[ ]
>>>>>    tcName    = STRTRAN([ ]+UPPER(tcName)+[ ],m.LookFor,m.ReplaceWith)
>>>>>ENDFOR
>>>>>
>>>>
>>>>Ok, that worked. Mostly. The other thing that is happening is that tcName is getting converted to uppercase, which is not what I want. How can I preserve the case and still get a valid replacement?
>>>
>>>You can't unfortunately. You should use other approach:
>>>
>>>m.ReplaceWith = ''
>>>m.PrefixSearchString = [ MR MRS MS MISS DR PROF SIR MASTER REV REVERAND ETC ]
>>>m.lcNewName = []
>>>FOR x = 1 TO GETWORDCOUNT( m.PrefixSearchString )
>>>    m.LookFor = ALLTRIM(UPPER(GETWORDNUM(m.PrefixSearchString,x)))+[ ]
>>>    lnAt      = AT(m.LookFor,UPPER(tcName)+[ ]) # 0
>>>    DO WHILE lnAt # 0
>>>       m.lcNewName = LEFT(tcName, lnAt-1) + m.LookFor + SUBSTR(m.tcName, lnAt+LEN(m.LookFor))
>>>       tcName      = SUBSTR(m.tcName, lnAt+LEN(m.LookFor))
>>>       lnAt        = AT(m.LookFor,UPPER(tcName)+[ ]) # 0
>>>   ENDDO
>>>ENDFOR
>>>tcName = IIF(EMPTY(m.lcNewName),m.tcName, m.lcNewName)
>>>
>>>That is NOT tested at all.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform