home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / Chip_2000-02_cd.bin / zkuste / Delphi / navody / tt / objvm.exe / UNITS / ConstValues.pas < prev    next >
Pascal/Delphi Source File  |  1998-06-26  |  2KB  |  71 lines

  1. unit ConstValues;
  2.  
  3. interface
  4. uses LangValue,
  5.      NamedValuesList,ProxyValue,VisualValue;
  6. type
  7.        {Constant value set }
  8.      TConstValues=class(ILangValue)
  9.      protected
  10.         Variables:TNamedValuesList;
  11.         function  rdValues(const s:string):ILangValue;override;
  12.      public
  13.         constructor Create;
  14.         destructor  Destroy;override;
  15.         function  HasValue(const s:string):boolean;override;
  16.         procedure AddValue(const s:string;a:ILangValue);override;
  17.         function  CreateEqu:ILangValue;override;
  18.         procedure RemoveValue(a:ILangValue);override;
  19.         procedure AddTo(a:IValueOwner);
  20.      end;
  21. implementation
  22. uses SysUtils;
  23. function    TConstValues.rdValues;
  24.             Var a:TProxyValue;
  25.             begin
  26.               Result:=Variables.ValByName(s);
  27.               if Result=nil then raise Exception.Create(s+' - φσ φαΘΣσφε');
  28.               Result:=TProxyValue.CreateFrom(Result);
  29.             end;
  30. constructor TConstValues.Create;
  31.             begin
  32.               inherited Create(nil);
  33.               Variables:=TNamedValuesList.Create;
  34.             end;
  35. destructor  TConstValues.Destroy;
  36.             begin
  37.               Variables.Free;
  38.               inherited Destroy;
  39.             end;
  40. function    TConstValues.HasValue;
  41.             begin
  42.               Result:=Variables.ValByName(s)<>nil;
  43.             end;
  44. procedure   TConstValues.AddValue;
  45.             begin
  46.               Variables.Add(s,a);
  47.             end;
  48. function    TConstValues.CreateEqu;
  49.             begin
  50.               Result:=TProxyValue.CreateFrom(Self);
  51.             end;
  52. procedure   TConstValues.RemoveValue(a:ILangValue);
  53.             begin
  54.               Variables.DeleteValue(a);
  55.             end;
  56. procedure   TConstValues.AddTo(a:IValueOwner);
  57.             Var i:Integer;
  58.                 v:TVisualValue;
  59.             begin
  60.               for i:=0 to Variables.Count-1 do
  61.               begin
  62.                 if Variables[i] is TVisualValue then
  63.                 begin
  64.                   v:=(Variables[i] as TVisualValue).CreateSame(a);
  65.                   v.LangOwner:=a;
  66.                 end;
  67.               end;
  68.             end;
  69.  
  70. end.
  71.