我有另一个问题!请看这个例子:
// There is a class with some method:
type
TMyClass = class
public
procedure Proc1;
end;
// There is a some thread class:
TMyThread = class(TThread)
protected
procedure Execute; override;
end;
procedure TMyClass.Proc1;
begin
// this method is just calling another thread:
with TMyThread.Create(True) do
begin
FreeOnTerminate := True;
Resume;
end;
// + there are some more actions
end;
procedure TMyThread.Execute;
begin
// in this example this thread just throws exception:
raise Exception.Create('Some exception');
end;
Run Code Online (Sandbox Code Playgroud)
所有我想要的 - 是在TMyClass.Proc1中引发异常并将其抛出如下:
var …Run Code Online (Sandbox Code Playgroud) 我只是想从指定的文本文件中删除前N个字符,但我卡住了.请帮帮我!
procedure HeadCrop(const AFileName: string; const AHowMuch: Integer);
var
F: TextFile;
begin
AssignFile(F, AFileName);
// what me to do next?
// ...
// if AHowMuch = 3 and file contains"Hello!" after all statements
// it must contain "lo!"
// ...
CloseFile(F);
end;
Run Code Online (Sandbox Code Playgroud)
我试图使用TStringList,但它还附加了行尾字符!
with TStringList.Create do
try
LoadFormFile(AFileName); // before - "Hello!"
// even there are no changes...
SaveToFile(AFileName); // after - "Hello!#13#10"
finally
Free;
end;
Run Code Online (Sandbox Code Playgroud)
谢谢!
可以在Delphi 5中用自定义值声明枚举吗?
type
MyEnum = (meVal1 = 1, meVal2 = 3); // compiler error
Run Code Online (Sandbox Code Playgroud)
谢谢!
我只想更改这个XML(包含在XMLTYPE变量中)名为"ChildNode"的所有节点,其中"Name"="B"属性值为"C":
<RootNode>
<ChildNodes>
<ChildNode Name="A"/>
<ChildNode Name="B"/>
</ChildNodes>
</RootNode>
DECLARE
FXML XMLTYPE;
BEGIN
FXML := ...; -- see text before
-- what next?
END;
Run Code Online (Sandbox Code Playgroud)
谢谢!
这是我的代码示例:
type
TMyBaseClass = class
public
procedure SomeProc; virtual;
end;
TMyChildClass = class(TMyBaseClass)
public
procedure SomeProc; override;
end;
var
SomeDelegate: procedure of object;
procedure TMyBaseClass.SomeProc;
begin
ShowMessage('Base proc');
end;
procedure TMyChildClass.SomeProc;
begin
ShowMessage('Child proc');
// here i want to get a pointer to TMyBaseClass.SomeProc (NOT IN THIS CLASS!):
SomeDelegate := SomeProc;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with TMyChildClass.Create do
try
// there will be "Child proc" message:
SomeProc;
finally
Free;
end;
// there i want to get "Base proc" message, …Run Code Online (Sandbox Code Playgroud)