| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 940 人关注过本帖
标题:请大家帮我看一下这段代码。为什么不能运行成功?应该怎样修改呢???
只看楼主 加入收藏
章三
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-11
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
请大家帮我看一下这段代码。为什么不能运行成功?应该怎样修改呢???
首先给出错误提示,以便对症下药:
  [Error] Analyse.pas(121): Undeclared identifier: 'wcchart'
  [Error] Analyse.pas(122): Undeclared identifier: 'wcseries'
  [Error] Analyse.pas(135): Not enough actual parameters
  [Error] Analyse.pas(141): Not enough actual parameters
  [Error] Analyse.pas(145): Not enough actual parameters
  [Error] Analyse.pas(146): Not enough actual parameters
  [Error] Analyse.pas(149): Undeclared identifier: 'autofitcolumns'
  [Error] Analyse.pas(150): Undeclared identifier: 'set_halignment'
  [Error] Analyse.pas(150): Undeclared identifier: 'sshalignleft'
  [Error] Analyse.pas(162): Missing operator or semicolon
  [Error] Analyse.pas(162): Missing operator or semicolon
  [Error] Analyse.pas(163): Missing operator or semicolon
  [Error] Analyse.pas(165): Undeclared identifier: 'axes'
  [Error] Analyse.pas(165): Missing operator or semicolon
  [Error] Analyse.pas(165): Missing operator or semicolon
  [Error] Analyse.pas(170): Missing operator or semicolon
  [Error] Analyse.pas(172): Undeclared identifier: 'majorunit'
  [Error] Analyse.pas(173): Undeclared identifier: 'hasmajorgridlines'
  [Error] Analyse.pas(175): Undeclared identifier: 'haslegend'
  [Error] Analyse.pas(176): Undeclared identifier: 'legend'
  [Error] Analyse.pas(176): Incompatible types: 'TPosition' and 'Integer'
  [Error] Analyse.pas(178): '.' expected but ';' found
  [Error] Analyse.pas(183): Undeclared identifier: 'wcchart'
  [Error] Analyse.pas(184): Undeclared identifier: 'wcseries'
  [Error] Analyse.pas(197): Not enough actual parameters
  [Error] Analyse.pas(202): Not enough actual parameters
  [Error] Analyse.pas(207): Not enough actual parameters
  [Error] Analyse.pas(208): Not enough actual parameters
  [Error] Analyse.pas(212): Undeclared identifier: 'autofitcolumns'
  [Error] Analyse.pas(213): Undeclared identifier: 'set_halignment'
  [Error] Analyse.pas(213): Undeclared identifier: 'sshalignleft'
  [Error] Analyse.pas(227): Missing operator or semicolon
  [Error] Analyse.pas(227): Missing operator or semicolon
  [Error] Analyse.pas(228): Missing operator or semicolon
  [Error] Analyse.pas(231): Undeclared identifier: 'axes'
  [Error] Analyse.pas(231): Missing operator or semicolon
  [Error] Analyse.pas(231): Missing operator or semicolon
  [Error] Analyse.pas(236): Missing operator or semicolon
  [Error] Analyse.pas(237): Undeclared identifier: 'majorunit'
  [Error] Analyse.pas(238): Undeclared identifier: 'hasmajorgridlines'
  [Error] Analyse.pas(244): Undeclared identifier: 'haslegend'
  [Error] Analyse.pas(245): Undeclared identifier: 'legend'
  [Error] Analyse.pas(245): Incompatible types: 'TPosition' and 'Integer'
  [Warning] Analyse.pas(247): Text after final 'END.' - ignored by compiler
  [Error] Analyse.pas(23): Unsatisfied forward or external declaration: 'TAnalyseForm.analyselend'
  [Error] Analyse.pas(24): Unsatisfied forward or external declaration: 'TAnalyseForm.analyseall'
  [Error] Analyse.pas(25): Unsatisfied forward or external declaration: 'TAnalyseForm.FormShow'
  [Error] Analyse.pas(26): Unsatisfied forward or external declaration: 'TAnalyseForm.Button2Click'
  [Error] Analyse.pas(27): Unsatisfied forward or external declaration: 'TAnalyseForm.SpeedButton1Click'
  [Error] Analyse.pas(28): Unsatisfied forward or external declaration: 'TAnalyseForm.SpeedButton2Click'
  [Fatal Error] BookManager.dpr(22): Could not compile used unit 'Analyse.pas'
unit Analyse;
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ToolWin,ExtCtrls,buttons, ADODB, ImgList,
  OleCtrls, ComObj,msdatasrc_tlb,myclass, ExtDlgs, OWC11_TLB;

type
  TAnalyseForm = class(TForm)
    Panel1: TPanel;
    ChartSpace1: TChartSpace;
    Panel2: TPanel;
    Spreadsheet1: TSpreadsheet;
    Panel3: TPanel;
    SaveDialog1: TSaveDialog;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure CreateParams(var Params: TCreateParams); override;
    procedure FormCreate(Sender: TObject);
    procedure analysesave;
    procedure analyseSell;
    procedure analyselend;
    procedure analyseall;
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
 private
   procedure WMPAINT1(var msg:TMESSAGE);message WM_PAINT;
   procedure WMNCPAINT1(var msg:TWMNCPAINT);message WM_NCPAINT;
   procedure Active(var msg:Tmessage);message WM_ACTIVATE;
   procedure sizing(var msg:Tmessage);message WM_SIZing;
   procedure WMNCLBUTTONDBLCLK1(var msg:Tmessage);message WM_NCLBUTTONDBLCLK;
       { Private declarations }
  public
    HowAna:Howanalyse;
    titleBmp:Tbitmap;
    { Public declarations }
  end;

implementation

uses MainForm,DataModule;
{$R *.dfm}
procedure TAnalyseForm.WMNCLBUTTONDBLCLK1(var msg:Tmessage);
begin
  //
end;
procedure TAnalyseForm.Active(var msg:Tmessage);
begin
  self.WMPAINT1(msg);
end;

procedure TAnalyseForm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  params.Style:=params.Style-WS_SYSMENU+WS_SIZEBOX;
end;

procedure TAnalyseForm.sizing(var msg:TMEssage);
var
 rectp:^Prect;
begin
  rectp:=@(msg.LParam);
  if  rectp^.Bottom-rectp^.Top <= 100 then
  begin
    rectp^.Bottom:=rectp^.top+100;//getsystemmetrics(sm_cycaption)+getsystemmetrics(sm_cyframe)*4+toolbar1.Height;
  end;
  if  rectp^.Right-rectp^.Left <= 400 then
  begin
    rectp^.Right:=rectp^.left+400;//getsystemmetrics(sm_cycaption)+getsystemmetrics(sm_cyframe)*4+toolbar1.Height;
  end;
end;

procedure TAnalyseForm.WMPAINT1(var msg:TMESSAGE);
begin
  sendmessage(self.Handle,WM_NCPAINT,0,0);
  inherited;
end;

procedure TAnalyseForm.WMNCPAINT1(var msg:TWMNCPAINT);
var
  dc1:HDC;
  y,frame:integer;
  oldbrush:HBrush;
  oldpen,pen:HPEN;
  canvas:Tcanvas;
begin
  canvas:=Tcanvas.Create;
  dc1:=getwindowdc(Handle);
  y:=GetSystemMetrics(SM_CYSIZE);
  frame:=GetSystemMetrics(SM_CYSIZEFRAME);
  oldbrush:=selectobject(dc1,getstockobject(null_brush));
  pen:=createpen(PS_SOLID,1,rgb(155,155,155));
  oldpen:=selectobject(dc1,pen);
  RoundRect(dc1,0,0,Width,Height,12,12);
  pen:=createpen(PS_SOLID,frame*2-5,rgb(255,255,255));
  selectobject(dc1,pen);
  RoundRect(dc1,2,2,Width-2,Height-2,8,10);
  StretchBlt(dc1,frame,frame,Width-2*frame,y+frame div 2,titlebmp.Canvas.Handle,0,0,titlebmp.Width,titlebmp.Height,srccopy);
  canvas.Handle:=dc1;
  canvas.Brush.Style:=bsclear;
  canvas.TextOut(frame*3,(y-frame)div 2,self.Caption);
  selectobject(dc1,oldbrush);
  selectobject(dc1,oldpen);
  deleteObject(pen);
  canvas.Handle:=0;
  canvas.Free;
  releasedc(Handle,dc1);
end;

procedure TAnalyseForm.FormCreate(Sender: TObject);
begin
  titlebmp:=Tbitmap.Create;
  titlebmp.LoadFromResourceName(main.resource,'TItle');
end;

procedure TAnalyseForm.analysesave;  //save analyse
var
  chart:wcchart;
  series:wcseries;
  rs:_recordset;
  i,j:integer;
begin
  data.'select top 10 ID 编号,BookName 书名,SumInstore 库存 from booksave order by SumInStore desc';
  rs:=data.adocommand1.Execute;
  ///////////////////////////////////////////
  spreadsheet1.Cells.Clear;
  spreadsheet1.ActiveSheet.Cells.item[1,1].Select;
  j:=0;
  for i:=0 to rs.Fields.Count-1 do       // 读取字段名
  begin
    inc(j);
    spreadsheet1.ActiveSheet.Cells.Item[1,j].set_value(rs.Fields[i].Name);
  end;
  i:=1;
  while not rs.EOF do                   //读取数据
  begin
    for j:=1 to rs.Fields.Count do
      spreadsheet1.ActiveSheet.Cells.item[i+1,j].set_value(vartostr(rs.Fields[j-1].Value));
    rs.MoveNext;
    inc(i);
  end;
  spreadsheet1.ActiveSheet.Cells.item[i+1,1].set_value(olevariant('合计:'));      //统计
  spreadsheet1.ActiveSheet.Cells.item[i+1,3].set_value(olevariant('=sum(c2:c'+inttostr(i)+')'));
  with spreadsheet1.Range[spreadsheet1.cells.Item[1,1],spreadsheet1.Cells.item[10,rs.Fields.Count]] do
  begin
    autofitcolumns;
    set_halignment(sshalignleft);
  end;
  ///////////////////////////////////////////////////////////
  with chartspace1 do
  begin
    clear;
    refresh;
    datasource:=rs as msdatasrc_tlb.datasource;
    datamember:='';
  end;
  chartspace1.ChartLayout:=chChartLayoutHorizontal;
  chart:=chartspace1.Charts.Add(0);
  series:=chart.SeriesCollection.Add(0);
  series.Caption:='库存数量';
  with chart do begin
    axes.Add(chart.Axes[chaxispositionleft].Scaling,chaxispositionright,chvalueaxis);
    HasTitle:=true;
    title.Caption:='库存统计图';
    setdata(chdimcategories,0,1);
    setdata(chdimvalues,0,2);
    with axes[chaxispositionleft]do
    begin
      majorunit:=50;
      hasmajorgridlines:=false;
    end;
    haslegend:=true;
    legend.Position:=chlegendpositionbottom;
   end;
end;


procedure TAnalyseForm.analyseSell;     //sell analyse
var
  chart:wcchart;
  series:wcseries;
  rs:_recordset;
  i,j: integer;
begin
  data.'select top 10 BookId 编号,BookName 书名,sellcount 售出总数 from allsum order by sellcount desc';
  rs:=data.adocommand1.Execute;

/////////////////////////表格
  spreadsheet1.Cells.Clear;
  spreadsheet1.ActiveSheet.Cells.item[1,1].Select;
  j:=0;
  for i:=0 to rs.Fields.Count-1 do begin
    inc(j);
    spreadsheet1.ActiveSheet.Cells.Item[1,j].set_value(rs.Fields[i].Name);
  end;
  i:=1;
  while not rs.EOF do begin
    for j:=1 to rs.Fields.Count do
    spreadsheet1.ActiveSheet.Cells.item[i+1,j].set_value(vartostr(rs.Fields[j-1].Value));
    rs.MoveNext;
    inc(i);
  end;

  spreadsheet1.ActiveSheet.Cells.item[i+1,1].set_value(olevariant('合计:'));
  spreadsheet1.ActiveSheet.Cells.item[i+1,3].set_value(olevariant('=sum(c2:c'+inttostr(i)+')'));

  with spreadsheet1.Range[spreadsheet1.cells.Item[1,1],spreadsheet1.Cells.item[10,rs.Fields.Count]] do
  begin
    autofitcolumns;
    set_halignment(sshalignleft);
  end;

  ////////////////////////////

  with chartspace1 do
  begin
    clear;
    refresh;
    datasource:=rs as msdatasrc_tlb.datasource;
    datamember:='';
  end;
  chartspace1.ChartLayout:=chChartLayoutHorizontal;
  chart:=chartspace1.Charts.Add(0);
  series:=chart.SeriesCollection.Add(0);
  series.Caption:='销售总数量';
  with chart do begin
  // chDimHighValues
    axes.Add(chart.Axes[chaxispositionleft].Scaling,chAxisPositionRight,chvalueaxis);
    HasTitle:=true;
    title.Caption:='销售统计图';
    setdata(chdimcategories,0,1);
    setdata(chdimvalues,0,2);
    with axes[chaxispositionleft]do begin
      majorunit:=50;
      hasmajorgridlines:=false;
    end;
    with axes[chaxispositionright]do begin
      majorunit:=25;
      hasmajorgridlines:=false;
    end;
    haslegend:=true;
    legend.Position:=chlegendpositionbottom;
  end;
end;


procedure TAnalyseForm.analyselend;   //lend analyse
var
  chart:wcchart;
  series:wcseries;
  rs:_recordset;
  i,j:integer;
begin
  data.'select top 10 BookId 编号,BookName 书名,LendTimes 借阅次数 from allsum order by lendtimes desc';
  rs:=data.adocommand1.Execute;
  ///////////////////////////////////////////
  spreadsheet1.Cells.Clear;
  spreadsheet1.ActiveSheet.Cells.item[1,1].Select;
  j:=0;
  for i:=0 to rs.Fields.Count-1 do begin
    inc(j);
    spreadsheet1.ActiveSheet.Cells.Item[1,j].set_value(rs.Fields[i].Name);
  end;
  i:=1;
  while not rs.EOF do begin
    for j:=1 to rs.Fields.Count do
      spreadsheet1.ActiveSheet.Cells.item[i+1,j].set_value(vartostr(rs.Fields[j-1].Value));
    rs.MoveNext;
    inc(i);
  end;
  spreadsheet1.ActiveSheet.Cells.item[i+1,1].set_value(olevariant('合计:'));
  spreadsheet1.ActiveSheet.Cells.item[i+1,3].set_value(olevariant('=sum(c2:c'+inttostr(i)+')'));
  with spreadsheet1.Range[spreadsheet1.cells.Item[1,1],spreadsheet1.Cells.item[10,rs.Fields.Count]] do
  begin
    autofitcolumns;
    set_halignment(sshalignleft);
  end;
  ///////////////////////////////////////////////////////////
  with chartspace1 do
  begin
    clear;
    refresh;
    datasource:=rs as msdatasrc_tlb.datasource;
    datamember:='';
  end;
  chartspace1.ChartLayout:=chChartLayoutHorizontal;
  chart:=chartspace1.Charts.Add(0);
  series:=chart.SeriesCollection.Add(0);
  series.Caption:='借阅次数';
  with chart do begin
  // chDimHighValues
    axes.Add(chart.Axes[chaxispositionleft].Scaling,chAxisPositionRight,chvalueaxis);
    HasTitle:=true;
    title.Caption:='借阅统计图';
    setdata(chdimcategories,0,1);
    setdata(chdimvalues,0,2);
    with axes[chaxispositionleft]do begin
      majorunit:=50;
      hasmajorgridlines:=false;
    end;
    with axes[chaxispositionright]do begin
      majorunit:=25;
      hasmajorgridlines:=false;
    end;
    haslegend:=true;
    legend.Position:=chlegendpositionbottom;
  end;
end;


procedure TAnalyseForm.analyseall;   //all analyse
var
  chart:wcchart;
  series:wcseries;
  rs:_recordset;
  i,j:integer;
begin
  data.'select distinct top 10  BookId 编号,BookName 书名,LendTimes 借阅次数,sellcount 销售数量 from allsum order by sellcount desc';
  rs:=data.adocommand1.Execute;
  ///////////////////////////////////////////
  spreadsheet1.Cells.Clear;
  spreadsheet1.ActiveSheet.Cells.item[1,1].Select;
  j:=0;
  for i:=0 to rs.Fields.Count-1 do begin                    //field
    inc(j);
    spreadsheet1.ActiveSheet.Cells.Item[1,j].set_value(rs.Fields[i].Name);
  end;
  i:=1;
  while not rs.EOF do begin                               //data
    for j:=1 to rs.Fields.Count do
      spreadsheet1.ActiveSheet.Cells.item[i+1,j].set_value(vartostr(rs.Fields[j-1].Value));
    rs.MoveNext;
    inc(i);
  end;

  spreadsheet1.ActiveSheet.Cells.item[i+1,1].set_value(olevariant('合计:'));
  spreadsheet1.ActiveSheet.Cells.item[i+1,3].set_value(olevariant('=sum(c2:c'+inttostr(i)+')'));
  spreadsheet1.ActiveSheet.Cells.item[i+1,4].set_value(olevariant('=sum(d2:d'+inttostr(i)+')'));

  with spreadsheet1.Range[spreadsheet1.cells.Item[1,1],spreadsheet1.Cells.item[10,rs.Fields.Count]] do
  begin
    autofitcolumns;
    set_halignment(sshalignleft);
  end;
  ///////////////////////////////////////////////////////////
  with chartspace1 do
  begin
    clear;
    refresh;
    datasource:=rs as msdatasrc_tlb.datasource;
    datamember:='';
  end;
  chartspace1.ChartLayout:=chChartLayoutHorizontal;
  /// series1
  chart:=chartspace1.Charts.Add(0);
  series:=chart.SeriesCollection.Add(0);
  series.Caption:='借阅次数';
  series.type_:=chChartTypeColumnClustered;
  with chart do begin
  // chDimHighValues
    axes.Add(chart.Axes[chaxispositionleft].Scaling,chAxisPositionRight,chvalueaxis);
    HasTitle:=true;
    title.Caption:='综合统计图';
    setdata(chdimcategories,0,1);
    setdata(chdimvalues,0,2);
    with axes[chaxispositionleft]do begin
      majorunit:=50;
      hasmajorgridlines:=false;
    end;
    with axes[chaxispositionright]do begin
      majorunit:=25;
      hasmajorgridlines:=false;
    end;
      haslegend:=true;
      legend.Position:=chlegendpositionbottom;
  end;  ///series1

  /// series2
  series:=chart.SeriesCollection.Add(1);
  with series do begin
    Caption:='销售总量';
    setdata(chdimcategories,0,1);
    setdata(chdimvalues,0,3);
    //type_:=chChartTypeBarClustered;
    type_:=chChartTypeColumnClustered;
  end;
  /// series2

end;


procedure TAnalyseForm.FormShow(Sender: TObject);
begin
  case HowAna of
    HAsell:analyseSell;
    HAlend: analyselend;
    HAsave:analysesave;
    HAAll: analyseall;
  end;
end;

procedure TAnalyseForm.Button2Click(Sender: TObject);
begin
  close;
end;

procedure TAnalyseForm.SpeedButton1Click(Sender: TObject);
begin
  if savedialog1.Execute then
    spreadsheet1.ActiveSheet.Export(savedialog1.FileName,ssExportActionNone);
end;

procedure TAnalyseForm.SpeedButton2Click(Sender: TObject);
begin
  Close;
end;

end.
搜索更多相关主题的帖子: 成功 121 actual 
2013-05-16 09:49
AfterSchool
Rank: 2
等 级:论坛游民
帖 子:3
专家分:20
注 册:2013-5-20
收藏
得分:20 
Undeclared identifier:未定义的意思
如:var wcchart
Not enough actual parameters:没有足够的实际参数
Missing operator or semicolon:缺少操作符或分号
'.' expected but ';' found:ElSE前不允许有“;”


问题太多了,多练练就知道了,熟能生巧
2013-05-20 17:27
快速回复:请大家帮我看一下这段代码。为什么不能运行成功?应该怎样修改呢??? ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046844 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved