|
of_wordcap
|
|
Full name
|
pfc_n_cst_string.of_wordcap
|
Access
|
public
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_wordcap(string)
|
Name
|
Datatype
|
lb_capnext
|
boolean
|
lc_char
|
char
|
lc_string
|
char[]
|
li_pos
|
integer
|
ll_stringlength
|
long
|
ls_ret
|
string
|
public function string of_wordcap (string as_source);//////////////////////////////////////////////////////////////////////////////
// Public Function: of_WordCap
// Arguments: as_source The source string.
// Returns: String Returns string with the first letter of each word set to
// uppercase and the remaining letters lowercase if it succeeds
// and NULL if an error occurs.
// If any argument's value is NULL, function returns NULL.
// Description: Sets the first letter of each word in a string to a capital
// letter and all other letters to lowercase (for example,
// ROBERT E. LEE would be Robert E. Lee).
//////////////////////////////////////////////////////////////////////////////
// Rev. History Version
// 5.0 Initial version
// 7.0 Fix to not capitalize the next character after apostrophe
//////////////////////////////////////////////////////////////////////////////
// Copyright © 1996-1999 Sybase, Inc. and its subsidiaries. All rights reserved. Any distribution of the
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
integer li_pos
boolean lb_capnext
string ls_ret
long ll_stringlength
char lc_char, lc_string[]
//Check parameters
If IsNull(as_source) Then Return as_source
//Get and check length
ll_stringlength = Len(as_source)
If ll_stringlength = 0 Then Return as_source
//Convert all characters to lowercase and put it into Character Array
lc_string = Lower(as_source)
//The first character should be capitalized
lb_capnext = TRUE
//Loop through the entire string
For li_pos = 1 to ll_stringlength
//Get one character at a time
lc_char = lc_string[li_pos]
If lc_char = "'" Then
lb_capnext = False
ElseIf Not of_IsAlpha(lc_char) Then
//The next character should be capitalized
lb_capnext = True
ElseIf lb_capnext Then
//Capitalize this Alphabetic character
lc_string[li_pos] = Upper(lc_char)
//The next character should not be capitalized
lb_capnext = False
End If
Next
//Copy the Character array back to a string variable
ls_ret = lc_string
return ls_ret
end function
Name
|
Owner
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.len |
systemfunctions
|
systemfunctions.lower |
systemfunctions
|
systemfunctions.upper |
systemfunctions
|
pfc_n_cst_string.of_isalpha |
pfc_n_cst_string
|