Kbase P135380: Sample code for parsing an input string and returning a sentence with the first letter of the first
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/2/2008 |
|
Status: Unverified
GOAL:
Sample code for parsing an input string and returning a sentence with the first letter of the first word capitalized
GOAL:
How to capitalize the first letter of the first word of a sentence
FACT(s) (Environment):
All Supported Operating Systems
Progress/OpenEdge Versions
FIX:
FUNCTION capitalizeSentences RETURNS CHARACTER
( INPUT pcString AS CHARACTER ):
DEFINE VARIABLE cSentence AS CHARACTER NO-UNDO.
DEFINE VARIABLE cConverted AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFormat AS CHARACTER NO-UNDO.
DEFINE VARIABLE iSentence AS INTEGER NO-UNDO.
DO iSentence = 1 TO NUM-ENTRIES(pcString,"."):
cSentence = TRIM(ENTRY(iSentence,pcString,".")).
IF (cSentence GT "") NE TRUE THEN NEXT.
cSentence = TRIM(STRING(cSentence,"!x(" +
STRING(LENGTH(cSentence)) + ")")) + ".".
cConverted = cConverted + (IF (cConverted GT "") EQ TRUE THEN " "
ELSE "") + cSentence.
END.
RETURN cConverted.
END FUNCTION.
DEFINE VARIABLE cString AS CHARACTER NO-UNDO.
cString = capitalizeSentences("sdkfjh sdkjfh isuh ruseh fkjhdkf jhsdkfh ksueh fkjsehfkj hsdkfjh. sdf sddf sdf sdklf woeui fksdfn ksdjf. " +
"sdf ws wfws4r frsv csd fsdf sdf. sdf SDF sdf sdf sdfsdf sdf fer fdf sdf sdf sdf. ").
MESSAGE cString
VIEW-AS ALERT-BOX INFO BUTTONS OK.