Written by

Sr Application Development Analyst at The Ohio State University Wexner Medical Center
Question Scott Roth · Feb 9, 2018

Mix case function

Does anyone have a function they built to change a name from all lower case, or all upper case to mix case?

Thanks

Scott Roth

Comments

Dmitry Maslennikov · Feb 9, 2018
USER>write $zcvt("mY sImPlE eXaMpLe", "W")
My Simple Example

$ZCONVERT

W or w Word translation: Convert the first character of each word in string to uppercase. Any character preceded by a blank space, a quotation mark ("), an apostrophe ('), or an open parenthesis (() is considered the first character of a word. Word translation converts all other characters to lowercase. Word translation is locale specific ; the above syntax rules for English may differ for other language locales.
S or s Sentence translation: Convert the first character of each sentence in string to uppercase. The first non-blank character of string, and any character preceded by a period (.), question mark (?), or exclamation mark (!) is considered the first character of a sentence. (Blank spaces between the preceding punctuation character and the letter are ignored.) If this character is a letter, it is converted to uppercase. Sentence translation converts all other letter characters to lowercase. Sentence translation is locale specific ; the above syntax rules for English may differ for other language locales.
0
Robert Cemper  Feb 9, 2018 to Dmitry Maslennikov

small extension.

USER>write $TR($zcvt("mY sImPlE eXaMpLe", "W")," ")
MySimpleExample
0
Scott Roth  Feb 16, 2018 to Dmitry Maslennikov

I have run into a case where the Last Name or First Name contains a Hyphen but no spaces between the Hyphen and the split name. I have tried "S", but that seemed not to help.

Anyone have suggestions on how to handle names with a hyphen besides doing an IF statement, and Piecing the Name apart to make it Proper Case?

0
Scott Roth  Feb 9, 2018 to Robert Cemper

Thanks did not realize that Cache had a function built in for that.

0
Dmitry Maslennikov  Feb 16, 2018 to Scott Roth

replace Hyphen to tab may help

write $tr($zcvt($tr("JOHN SMITH-DOW", "-", $c(9)), "W"), $c(9), "-")
John Smith-Dow
0
Robert Cemper · Feb 16, 2018

if you just want to eliminate the hyphen this may work for you:

USER>write $TR($zcvt($tr("mY-sImPlE eXaMpLe","-"," "),"W")," ")
MySimpleExample


translate hyphen to blank  first and off you go  

0