这是一道循环队列演示程序
错误提示:[Hint] ssUnit1.pas(159): Variable 'ifreq' is declared but never used in 'TForm1.butrdClick'
unit ssUnit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    comb1: TComboBox;
    Panel1: TPanel;
    butrd: TButton;
    butcd: TButton;
    butzd: TButton;
    buttc: TButton;
    PaintBox1: TPaintBox;
    Timer1: TTimer;
    procedure butrdClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type  tcq=class
   private
     front,rear:integer;
     elem:array[0..11]of char;
   public
     procedure init;
     function enq(el:char):boolean;
     function dlq:char;
     procedure prt;
     function geth:char;
     end;var
  Form1: TForm1;implementation
var q1:tcq;
  ax,ay:array[0..11]of integer;
{$R *.dfm}{ tcq }function tcq.dlq: char;
var ch:char;
begin
  if rear=front then
  dlq:=' '
  else
  begin
    ch:=elem[front];
    front:=(front+1)mod 11;
    dlq:=ch;
    endend;function tcq.enq(el: char): boolean;
begin
  if (rear+1)mod 11=front then enq:=false       //[Hint] ssUnit1.pas(159): Variable 'ifreq' is declared but never used in 'TForm1.butrdClick'
  else
  begin
    elem[rear]:=el;
    rear:=(rear+1)mod 11;
    enq:=true;
    end
end;function tcq.geth:char;
begin
  if rear=front then
  geth:=' '
  else
  geth:=elem[front];
end;procedure tcq.init;
begin
 front:=0;
 rear:=0;
end;procedure tcq.prt;
var ip,i,ix,iy,ix0,iy0:integer;
     rect1:trect;
     s:string[25];
begin
  rect1:=rect(0,0,200,200);
   form1.PaintBox1.Canvas.Brush.Color :=clbtnface;
   form1.PaintBox1.Canvas.FillRect(rect1);
   form1.PaintBox1.Canvas.Pen.Color:=clblack;
   form1.PaintBox1.Canvas.Pen.Width:=1;
   form1.PaintBox1.Canvas.Font.Color:=clred;
   form1.PaintBox1.Canvas.Font.Size:=15;
   form1.PaintBox1.Canvas.Brush.Color:=clwhite;
   form1.PaintBox1.canvas.Ellipse(21,21,180,180);
   form1.PaintBox1.canvas.Brush.Color :=clbtnface;
   form1.PaintBox1.Canvas.Ellipse(51,51,150,150);
   for i:=0 to 11 do
      begin
        ix0:=100+round(50*cos(pi*i/6));
        iy0:=100-round(50*sin(pi*i/6));
        form1.PaintBox1.Canvas.MoveTo(ix0,iy0);
        ix:=100+round(80*cos(pi*i/6));
        iy:=100-round(80*sin(pi*i/6));
        form1.PaintBox1.Canvas.LineTo (ix,iy);
        end;
        form1.PaintBox1.Canvas.Brush.Color :=clred;
        form1.PaintBox1.Canvas.Pen.Color :=clred;
        ix0:=100+round(30*cos(pi*front/6+pi/12));
        iy0:=100-round(30*sin(pi*front/6+pi/12));
        form1.PaintBox1.Canvas.Ellipse(ix0-3,iy0-3,ix0+3,iy0+3);
        form1.PaintBox1.Canvas.Brush.Color :=clwhite;
        form1.PaintBox1.Canvas.Pen.Color :=clwhite;
        ix0:=100+round(40*cos(pi*rear/6+pi/12));
        iy0:=100-round(40*sin(pi*rear/6+pi/12));
        form1.PaintBox1.Canvas.Ellipse(ix0-3,iy0-3,ix0+3,iy0+3);
        form1.PaintBox1.Canvas.Brush.Color:=clbtnface;
        form1.PaintBox1.Canvas.Pen.Color :=clred;
        form1.PaintBox1.Canvas.Pen.Width :=1;
        if front<>rear then
        begin
           ip:=front;
           while ip<>rear do
           begin
             for i:=1 to 9 do
               begin
                 ix0:=100+round(50*cos(pi*ip/6+pi*i/60));
                 iy0:=100-round(50*sin(pi*ip/6+pi*i/60));
                 form1.PaintBox1.Canvas.MoveTo(ix0,iy0);
                 ix:=100+round(80*cos(pi*ip/6+pi*i/60));
                 iy:=100-round(80*sin(pi*ip/6+pi*i/60));
                 form1.PaintBox1.Canvas.LineTo(ix,iy);
                 end;
              s:=elem[ip];
              ix:=ax[ip];
              iy:=ay[ip];
              form1.PaintBox1.Canvas.TextOut(ix,iy,s);
              ip:=(ip+1)mod 11;
              end
             end
end;procedure TForm1.butrdClick(Sender: TObject);
var ifreq:integer;
    ch:char;
begin
  ch:=comb1.Text[1];
  if q1.enq(ch)then q1.prt
  else
  showmessage('full');
end;end.

解决方案 »

  1.   

    procedure TForm1.butrdClick(Sender: TObject);
    var ifreq:integer;
        ch:char;
    begin
      ch:=comb1.Text[1];
      if q1.enq(ch)then q1.prt
      else
      showmessage('full');
    end;把这个过程中的变量申明IFreq去掉就可以了,这个只是编译警告不是什么错误!
      

  2.   

    FrameSniper(★框架狙击手★№2)->正确
      

  3.   

    去掉后,错误还是指向
    function tcq.enq(el: string): boolean;
    begin
      if (rear+1)mod 12=front then enq:=false //错误老指向这时里,没有错误提示
      else
      begin
        elem[rear]:=el;
        rear:=(rear+1)mod 12;
        enq:=true;
        end
    end;
      

  4.   

    写错了
    去掉后,错误还是指向
    function tcq.enq(el: char): boolean;
    begin
      if (rear+1)mod 11=front then enq:=false //错误老指向这时里,没有错误提示
      else
      begin
        elem[rear]:=el;
        rear:=(rear+1)mod 11;
        enq:=true;
        end
    end;