LCWORD2: Converting a Character String to Mixed-Case

How to:

The LCWORD2 function converts the letters in a character string to mixed-case by converting every alphanumeric character to lowercase except the first letter of each new word. LCWORD2 leaves any character after a single quotation mark as upper case, except that when there is at least one non-blank character before the quote and just one character followed by either the end of the string or a space immediately after the quote, the next letter is converted to lowercase For example, 'O’CONNOR' would be changed to 'O’Connor,' and JACK'S would be changed to Jack's.


Top of page

x
Syntax: How to Convert a Character String to Mixed-Case
LCWORD2(length, string, outfield)

where:

length

Integer

Is the length in characters of the character string or field to be converted, or a field that contains the length.

string

Alphanumeric

Is the character string to be converted, or a temporary field that contains the string.

outfield

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks. The length must be greater than or equal to the length of length.



Example: Converting a Character String to Mixed-Case

LCWORD2 converts the string O'CONNOR’s to mixed-case:

DEFINE FILE EMPLOYEE
MYVAL1/A10='O'CONNOR'S';
LC2/A10 = LCWORD2(10, MYVAL1, 'A10');
END
TABLE FILE EMPLOYEE
SUM LAST_NAME NOPRINT MYVAL1 LC2 
END

The output is:

MYVAL1      LC2
------      --- 
O'CONNOR'S  O'Connor's

Information Builders