子
子瑜
Unregistered / Unconfirmed
GUEST, unregistred user!
如题:如何获取过程或函数中的动态变化值,如下例:
test(var varp:integer)
想在函数运行过程中,动态取出varp的值,如何实现?
完整例子如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Function test(var varp:integer):Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Function TForm1.test(var varp:integer):Boolean;
var
j:integer;
begin
Result:=False;
For j:=0 to 10000 do
begin
varp:=j;
application.ProcessMessages;
end;
Result:=True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
flag:boolean;
myvarp:integer;
begin
flag:=False;
repeat
flag:=test(myvarp);
Caption:=inttostr(myvarp);
application.ProcessMessages;
until Flag;
end;
end.
test(var varp:integer)
想在函数运行过程中,动态取出varp的值,如何实现?
完整例子如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Function test(var varp:integer):Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Function TForm1.test(var varp:integer):Boolean;
var
j:integer;
begin
Result:=False;
For j:=0 to 10000 do
begin
varp:=j;
application.ProcessMessages;
end;
Result:=True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
flag:boolean;
myvarp:integer;
begin
flag:=False;
repeat
flag:=test(myvarp);
Caption:=inttostr(myvarp);
application.ProcessMessages;
until Flag;
end;
end.