Hi, I been making a little text editor and I am adding in some features to deal with converting a selection of text, I got the uppercase,lowercase and toggle-case working however I am stuck on the capitalize case, what I done so far is made it so you can select a string with a space after each word and it will uppercase the first letter after the space.
I want to add support for TABS also the code below works with tabs but if you insert a space before or after the tab is does not uppercase the next none space char can someone please have a look what I have done wrong thanks.
function Capitalize(const S : String) : String;
var
flag : Boolean;
S1 : String;
CH : String;
X : Integer;
begin
flag := True;
S1 := '';
For X := 1 to Length(S) do begin
CH := Copy(S,X,1);
if flag then
begin
if (CH <> ' ') or (CH <> #9) then begin
S1 := S1 + UpperCase(CH);
flag := False;
end
else
begin
S1 := S1 + CH;
end;
end
else
begin
S1 := S1 + Lowercase(CH);
flag := (CH = ' ') OR (ch = #9);
end;
end;
Result := S1;
end;