希望我只是遗漏了一些明显的东西,但我似乎发现在使用Delphi XE5 Android编译器时,常量字符串参数被破坏了.测试代码:
1)创建一个新的空白移动应用程序项目.
2)TButton在表单中添加一个,并为其创建一个OnClick处理程序.
3)像这样填写处理程序:
procedure TForm1.Button1Click(Sender: TObject);
begin
GoToDirectory(PathDelim + 'alpha' + PathDelim + 'beta');
GoToDirectory(FParentDir);
end;
Run Code Online (Sandbox Code Playgroud)
4)在表单类声明中,添加两个字段和一个方法,如下所示:
FCurrentPath, FParentDir: string;
procedure GoToDirectory(const Dir: string);
Run Code Online (Sandbox Code Playgroud)
5)实施Foo和GoToDirectory喜欢:
function Foo(const S: string): Boolean;
begin
Result := (Now <> 0);
end;
procedure TForm1.GoToDirectory(const Dir: string);
begin
FCurrentPath := IncludeTrailingPathDelimiter(Dir);
FParentDir := ExcludeTrailingPathDelimiter(ExtractFilePath(Dir));
ShowMessageFmt('Prior to calling Foo, Dir is "%s"', [Dir]);
Foo(FParentDir);
ShowMessageFmt('After calling Foo, Dir is "%s"', [Dir]);
end;
Run Code Online (Sandbox Code Playgroud)
6)编译并在设备上运行.
当我这样做时,前两个消息框没有指出任何错误,但是Dir然后在第三和第四个提示之间清除.有没有其他人得到这个,或者我只是做一些愚蠢的事情?(当我为测试目的而定位Win32时,没有什么不好的.) …