Hi!
You are wrong! Your procedure has got 7 lines. You also have to count the "ProcedureReturn"-line!
I recommend you, to protect your variables by using "Protected".
Here is my version, it uses recursive calls instead of a FOR-Loop. I replaced Left() and Right() by PeekS(). If you use PeekS() with the right *pointer, then it's faster than Right() and Left(). Moreover, I don't use Trim() which makes my procedure even faster. Moreover, you can choose, which separator you want to youse.
Code: Select all
Procedure.s Capital_Letter(string.s, separator.s=" ")
Protected word.s=StringField(string, 1, separator), recursive_call.s=PeekS(@string+Len(word)+1)
word=UCase(PeekS(@word, 1))+LCase(PeekS(@word+1))
If recursive_call
word+separator+Capital_Letter(recursive_call, separator)
EndIf
ProcedureReturn word
EndProcedure
Debug Capital_Letter("the QUICK bRoWn fOx jUMPs ovER thE Lazy dog.")
Debug Capital_Letter("jackdaws+LOVE+my+bIg+sphinX+oF+quArZ.", "+")
A problem occured. Does anybody know, why there is garbage at the end of the debugged line?
When I compiled my code the first time, everything was ok. Second time, too. Then I changed the string and from now on, I get this:
Debugger wrote:The Quick Brown Fox Jumps Over The Lazy Dog. ) X)
Jackdaws+Love+My+Big+Sphinx+Of+Quarz.+L+Rx)+ç+)¼
Why? Before psoting this ocde, my code also supported Unicode (PeekS()), I removed this support due to this error.