1 {
2 *****************************************************************************
3 * *
4 * This file is part of the ZCAD *
5 * *
6 * See the file COPYING.modifiedLGPL.txt, included in this distribution, *
7 * for details about the copyright. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
12 * *
13 *****************************************************************************
14 }
15 {
16 @author(Andrey Zubarev <zamtmn@yandex.ru>)
17 }
18 unit uzcvariablesutils;
19 {$INCLUDE def.inc}
20
21 interface
22 uses uzcenitiesvariablesextender,sysutils,UGDBOpenArrayOfPV,uzbtypesbase,uzbtypes,
23 gzctnrvectortypes,uzeentity,varmandef,uzeentsubordinated;
24 //**поиск значения свойства по имени varname:gdbstring которое было в ведено в инспекторе для данного устройства PEnt:PGDBObjEntity
25 //**возвращает
FindVariableInEntnull26 function FindVariableInEnt(PEnt:PGDBObjEntity;varname:gdbstring):pvardesk;
FindEntityByVarnull27 function FindEntityByVar(arr:GDBObjOpenArrayOfPV;objID:GDBWord;vname,vvalue:GDBString):PGDBObjSubordinated;
28 implementation
FindVariableInEntnull29 function FindVariableInEnt(PEnt:PGDBObjEntity;varname:gdbstring):pvardesk;
30 var
31 pentvarext:PTVariablesExtender;
32 begin
33 pentvarext:=PEnt^.GetExtension(typeof(TVariablesExtender));
34 result:=nil;
35 if pentvarext<>nil then
36 result:=pentvarext^.entityunit.FindVariable(varname);
37 if result=nil then
38 if PEnt^.bp.ListPos.Owner<>nil then
39 result:=FindVariableInEnt(pointer(PEnt^.bp.ListPos.Owner),varname);
40 end;
FindEntityByVarnull41 function FindEntityByVar(arr:GDBObjOpenArrayOfPV;objID:GDBWord;vname,vvalue:GDBString):PGDBObjSubordinated;
42 var
43 pvisible:PGDBObjEntity;
44 ir:itrec;
45 pvd:pvardesk;
46 pentvarext:PTVariablesExtender;
47 begin
48 result:=nil;
49 begin
50 pvisible:=arr.beginiterate(ir);
51 if pvisible<>nil then
52 repeat
53 if pvisible.GetObjType=objID then
54 begin
55 pentvarext:=pvisible^.GetExtension(typeof(TVariablesExtender));
56 pvd:=pentvarext^.entityunit.FindVariable(vname);
57 if pvd<>nil then
58 begin
59 if pvd.data.PTD.GetValueAsString(pvd.data.Instance)=vvalue then
60 begin
61 result:=pvisible;
62 exit;
63 end;
64 end;
65 end;
66 pvisible:=arr.iterate(ir);
67 until pvisible=nil;
68 end;
69 end;
70
71 end.
72
73