PowerBuilder Function WordCap gf_wordcap
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
//Function Name : gf_wordcap //Argument Name : as_source, Arg Type : String, Pass By : Value //Return Type : 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, // POWERBUILDER FUNCTION would be Powerbuilder Function). Integer li_pos Boolean lb_capnext String ls_ret Long ll_stringlength Char lc_char Char lc_string[] //Check parameters If IsNull(as_source) Then String ls_null SetNull(ls_null) Return ls_null End If //Get and check length ll_stringlength = Len(as_source) If ll_stringlength = 0 Then Return as_source End If //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 Not f_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 the Return ls_ret |
Good Luck!
Is this function a joke sir? Can you please tell me where is ——>gives error If Not f_IsAlpha(lc_char) Then
sorry. Here is it. https://pblib.com/knowledge-base/powerbuilder-function-is-alphabet/