Microsoft KB Archive/99544

= PROPER (Capitalization) Function for FoxBASE+/Mac =

PSS ID Number: 99544

Article Last Modified on 10/23/1999

-

The information in this article applies to:


 * Microsoft FoxBASE+ for Macintosh 2.01

-



This article was previously published under Q99544



SUMMARY
FoxBASE+/Mac currently does not have a PROPER function to capitalize the first letter of each word in a string. However, the code below was written to allow the use of a user-defined function (UDF) for a PROPER function.



MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code &quot;as is&quot; without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

To use the program below, follow these steps:

 Type the code below (&quot;Contents of PROPER.PRG&quot;) into a program file called PROPER.PRG. In the Command window or in your program, type the following:

set procedure to proper.prg

 Use PROPER like any other function.

Syntax of Proper
PROPER()

Example (Typed in the Command Window)
REPLACE ALL Roster->Last WITH PROPER(Roster->Last)

Contents of PROPER.PRG
* Beginning of PROPER.PRG

PARAMETERS STRING

IF TYPE('STRING') <> &quot;C&quot; WAIT &quot;Invalid Parameter Passed To PROPER&quot; RETURN &quot; &quot; ENDIF

IF LEN(RTRIM(STRING)) = 0 RETURN &quot;&quot; ENDIF

STORE 1 TO DD  STORE LEN(STRING) TO STRLEN

* Lower all characters STRING = LOWER(RTRIM(STRING))

* Check first character in string IF SUBSTR(STRING, 1, 1) <> &quot; &quot; STRING = UPPER(SUBSTR(STRING, 1, 1))+SUBSTR(STRING, 2) ENDIF

DO WHILE .T.      IF SUBSTR(STRING, DD, 1) = &quot; &quot; STRING = SUBSTR(STRING, 1, DD) ; +UPPER(SUBSTR(STRING, DD+1, 1))+SUBSTR(STRING, DD+2) ENDIF DD = DD + 1 IF DD > LEN(STRING) - 2 EXIT ENDIF ENDDO

IF LEN(STRING) < STRLEN STRING = STRING + SPACE(STRLEN-LEN(STRING)) ENDIF

RETURN STRING
 * End of Program

Additional query words: uppercase lowercase initial capital letters caps upper case lower

Keywords: KB99544

Technology: kbAudDeveloper kbFoxBASE201Mac kbFoxBASESearch kbFoxproSearch kbHWMAC kbOSMAC

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.