在 Delphi 10.4 Sydney 中,例如,如果您选择一个评论,//xxx然后按下{键盘上的press ,编辑器将自动将所选文本/评论替换为{//xxx}.
预期的行为是只{在屏幕上显示,而不是{//xxx}.
我如何停止这种行为?
我禁用了我所有的 IDE 专家,所以这必须来自 IDE 本身。
来自 LCL 和 Lazarus Pascal,我正在尝试将所有代码转换为 Delphi Pascal。
不工作的一行涉及 BinToHex:
function BinStr2Hex(S: AnsiString): AnsiString;
var
i: integer;
begin
Result := '';
for i := 1 to Length(S)
do Result := Result + AnsiLowerCase(BinToHex(Bytes(S[i]), 2));
end;
Run Code Online (Sandbox Code Playgroud)
这会引发未声明的标识符字节错误(不知道如何将其写为声明?)还是我必须使用 TBytes 来代替?
如果我将其更改为 TBytes,则会收到不同的错误 - 没有可以使用这些参数调用的“BixToHex”的重载版本。
我该如何在 Delphi 10.4 中正确地编写这个?
谢谢。
我正在将代码从 Lazarus 转换为 Delphi 10.4 Sydney 并且有一行抛出错误:
// Split line and put it into a new array, txtDataArray
txtDataArray := txtToParse.Split(['.', ',', '!'], TStringSplitOptions.ExcludeEmpty);
Run Code Online (Sandbox Code Playgroud)
txtToParse 是逗号分隔的文本变量。
我将如何正确编写它以在 Delphi 10.4 Sydney 中工作?
我试过这个,我得到一个错误,指出:
不兼容的类型 - 第 340 行的动态数组和系统 TArray<System String>:
在var我下面:
// For splitting
charArray : Array[0..2] of Char;
txtToParse : String;
txtArray : array of String;
Run Code Online (Sandbox Code Playgroud)
然后在主函数中我有:
// Split line and put it into a new array, txtArray
charArray[0] := '.';
charArray[1] := ',';
charArray[2] := '!';
txtArray …Run Code Online (Sandbox Code Playgroud) 我编写了一个应在启动 Windows 时运行的应用程序。
我使用此代码来使用复选框来决定它是否在启动时运行:
// d('randomString'); -> this is a function which adds text to a memo for debugging purposes
// GetDosOutput is a function to run cmd commands and get the output of them piped in a memo
function GetRegistryValue(KeyName: string): string;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ);
try
Registry.RootKey := HKEY_CURRENT_USER;
// False weil kein Eintrag erzeugt werden soll, sofern er nicht vorhanden ist.
Registry.OpenKey(KeyName, False);
result := Registry.ReadString('SomeRandomAppIWantToRun');
finally
Registry.Free;
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
var …Run Code Online (Sandbox Code Playgroud) 我已在主窗体中添加了一个已发布的事件,希望它会显示在编辑器中,但事实并非如此。我做错了什么,还是事实并非如此?
THIFISongEndEvent = procedure(Sender: TObject; EstimatedEndTime: TDateTime) of object;
TMain = class(TForm)
[...]
published
property OnSongEnd: THIFISongEndEvent read FOnSongEnd write SetOnSongEnd;
Run Code Online (Sandbox Code Playgroud)
编辑:添加代码
在 Javascript 中,如果我执行以下命令:
if (cond1 && cond2) {
}
Run Code Online (Sandbox Code Playgroud)
如果 cond1 为假,解析器将停止,无需检查 cond2。这对性能有好处。
以相同的方式 :
if (cond1 || cond2) {
}
Run Code Online (Sandbox Code Playgroud)
如果 cond1 为真,则无需检查 cond2。
在较新的 Delphi 版本上有类似的东西吗?我在 10.4
谢谢
所以我有一个“下载”文件夹,我把日常工作中下载的所有内容都放在其中。您知道我们总是将所有事情自动化,因此我尝试构建一个简单的应用程序来每天运行以删除超过 30 天的文件,因为我必须不时手动执行此操作以避免文件夹变得太大。
这是我的代码:
function TForm1.deleteOldDownloads: boolean;
var
f: string;
i, d: Integer;
var
sl: tstringlist;
begin
try
FileListBox1.Directory := '\\psf\home\downloads';
FileListBox1.refresh;
sl := tstringlist.create;
for i := 0 to FileListBox1.items.count - 1 do
begin
f := FileListBox1.Directory + '\' + FileListBox1.items[i];
if fileexists(f) then
d := daysbetween(FileAge(f), now)
else
d := 0;
if d > 30 then // problem is here, d is always a big number, not the actually age of file
sl.Add(f);
end;
if sl.count > 0 …Run Code Online (Sandbox Code Playgroud)