//=============================================================
#commands start at 7700
#include testree.sc end;
//=============================================================
TreeLine StatusLine
{
(scTree..scTree)
{
'~F7~ New', cmInsert, kbF7;
'~F8~ Delete', cmDelete, kbF8;
'F3', cmPick, kbF3;
'~+~ Open', cmTreeOpenNode, kbGrayPlus;
'~-~ Close', cmTreeCloseNode, kbGrayMinus;
}
}
//=============================================================
interface TreeWithoutTable (,,scTree);
//-------------------------------------------------------------
create view;
//-------------------------------------------------------------
var
myNumber: array [1..10] of integer; // номера записей
info : array [1..10] of string; // полезная информация
myOwner : array [1..10] of integer; // ссылка на родителя
curRec : integer; // текущая запись
cOwner : integer; // текущее ограничение для дерева
i : integer;
//-------------------------------------------------------------
tree myTree NoTableNavigation;
fields
info[curRec];
end;
//-------------------------------------------------------------
handleEvent
cmTreeTop:
cOwner := 0;
cmTreeUp:
cOwner := myOwner[curRec];
cmTreeDown:
cOwner := myNumber[curRec];
cmDoGetFirst:
{
for (i:=1; i<=10; i:=i+1)
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
if curRec <> i then
abort;
}
cmDoGetPrev:
{
if (curRec <= 1)
{
abort;
exit;
}
for (i:=curRec-1; i>=1; i:=i-1)
if (myOwner[i] = cOwner)
{
curRec := I;
break;
}
if curRec <> I then
abort;
}
cmDoGetNext:
{
if (curRec >= 10)
{
abort;
exit;
}
for (i:=curRec+1; i<=10; i:=i+1)
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
if curRec <> i then
abort;
}
cmDoGetLast:
{
for (i:=10; i>=1; i:=i-1)
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
if curRec <> i then
abort;
}
cmGetAddr:
ReturnPosition(curRec);
cmGetDirect:
curRec:=SetPosition;
cmDoFind:
{
var c : integer;
c := comp(SearchValue);
if (c < 1) or (c > 10) or (integer(c)) <> c then
{
Abort;
exit;
}
curRec := c;
}
end;
cmInit:
{
cOwner := 0;
curRec := 1;
for (i:=1; i<=10; i:=i+1)
{
info[i] := 'Информация #' + String(i);
myNumber[i] := i;
}
myOwner[1]:=0;
myOwner[2]:=0;
myOwner[3]:=0;
myOwner[4]:=1;
myOwner[5]:=3;
myOwner[6]:=3;
myOwner[7]:=4;
myOwner[8]:=7;
myOwner[9]:=8;
myOwner[10]:=9;
if (not TreeJumpToRecord(myTree, 9))
Message('Error');
}
cmTreeNeedOwner:
{
TreeJumpToRecord(myTree, myOwner[curRec]);
}
end;
end