编译时出现Invalid compiler directive: 'pnum' 怎么办!!
编写自动生成treeview的程序,编译时出现这问题,身为初学者琢磨了很久都没搞懂为什么。哪位路过的帮我看看哈!谢了!unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ComCtrls;
type
TForm4 = class(TForm)
Query1: TADOQuery;
TreeView1: TTreeView;
ADOConnection1: TADOConnection;
procedure FormShow(Sender: TObject);
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
type
Ttable= array[1..2000,1..2] of string;
Tindextable= array[1..2000,1..1] of integer;
var
pnode:TTreenode;
temptable:Ttable;
indextable:Tindextable
pnum:integer;
snum:integer;
itemlevel:integer;
sname:string;
procedure TForm4.FormShow(Sender: TObject);
begin
treeview1change(nil,nil);
end;
procedure TForm4.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
if treeview1.items.count<>0 then
begin
treeview1.items.Item[0].Delete ;
end;
query1.close;
query1.Open;
while not query1.Eof do
begin
pnum:=query1.fieldbyname('父编号').asinteger;
snum:=query1.fieldbyname('编号').asinteger;
sname:=query1.fieldbyname('名次').asstring;
itemlevel:=query1.fieldbyname('层次').asinteger;
temptable[snum,2]:=query1.fieldbyname('最大子号').asstring;
if (itemlevel=0) then
begin
pnode:=treeview1.Items.addfirst(nil,sname);
indextable[pnode.AbsoluteIndex+1,1]:=snum;
temptable[snum,1]:=inttostr(pnode.absoluteindex);
end
else
begin
pnode:=treeview1.items.item[strtoint(temptable[pnum,1])];
pnode:=treeview1.Items.AddChild(pnode,sname);
indextable[pnode.AbsoluteIndex+1,1]:=snum;
temptable[snum,1]:=inttostr(pnode.AbsoluteIndex );
end;
query1.next;
end;
end;
end.