这是我试图解决About.com Delphi challenge to un-camel-case a string。这段代码有什么问题来解开字符串?
unit challenge1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
check = 65..90;
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var s1,s2 :string;
int : integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
checks : set of check;
begin
s1 := edit1.Text;
for i := 1 to 20 do
begin
int :=ord(s1[i]) ;
if int in checks then
insert(' ',s1,i-1);
end;
showmessage(s1);
end;
end.
check
是一组包含大写字母所以基本上每当一个大写字母遇到插入功能的遭遇(在s1
字符串内)之前添加空间,但我的代码什么也不做。 ShowMessage
只显示文本,因为它是在Edit1
中输入的。我做错了什么?
为什么是空的? Uwe说没有定义,这对我更有意义。 – 2010-05-28 21:37:19