程序中有一个 procedure uss;
   当一个按钮按下的时候就执行了 。  可是再按下怎么退出这个uss呢 ??
  exit(uss); ??不对啊。

解决方案 »

  1.   

    给你个简单的过程
    var
      Form1: TForm1;
      IsExit:boolean=false;
    implementation{$R *.dfm}procedure uss;
    begin
    if IsExit then exit;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    IsExit:=not IsExit;
    if not IsExit then
       uss;
    end;
      

  2.   

    procedure uss; 
    begin
    ... //自杀代码 
    sleep(1000000);//如果程序中有个这个呢 ?~`` 
    if IsExit then exit;
    end; 这样正在执行也没有办法执行到最后一句不是 .. 
      

  3.   

    procedure uss; 
    begin 
    ... //自杀代码 
    for i:0 to 1000 do
    begin
      sleep(1000);//如果程序中有个这个呢 ?~``
      application.ProcessMessages; 
    end;
    if IsExit then exit; 
    end;