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

  1. unit LangVariable;
  2.  
  3. interface
  4. uses LangValue;
  5. type
  6.        { Variable for language }
  7.      TLangVariable=class(ILangValue)
  8.      protected
  9.         function  rdValues(const s:string):ILangValue;override;
  10.      public
  11.         Value:ILangValue;
  12.         constructor Create;
  13.         destructor  Destroy;override;
  14.         procedure Exec(S:IValStack;MustReturn:boolean);override;
  15.         function  HasValue(const s:string):boolean;override;
  16.         function  CreateEqu:ILangValue;override;
  17.      end;
  18. implementation
  19. uses VarLangValue,SysUtils,LangRef;
  20. const cRef='Ref';
  21. function  TLangVariable.rdValues;
  22.           begin
  23.             if S=cRef then
  24.               Result:=TLangRef.Create(Self)
  25.             else
  26.               Result:=Value.Values[s];
  27.           end;
  28. procedure TLangVariable.Exec;
  29.           begin
  30.             if S.FrameCount>1 then
  31.               raise Exception.Create('Try to assign more than 1 value');
  32.             if S.FrameCount>0 then
  33.             begin
  34.               Value.Free;
  35.               Value:=s.FrameValues[0].CreateEqu;
  36.             end;
  37.             s.DropFrame;
  38.             if MustReturn then
  39.             begin
  40.               S.Push(Value.CreateEqu);
  41.             end;
  42.           end;
  43. function  TLangVariable.HasValue;
  44.           begin
  45.             if s=cRef
  46.             then 
  47.               Result:=true
  48.             else
  49.               Result:=Value.HasValue(s);
  50.           end;
  51. function  TLangVariable.CreateEqu;
  52.           begin
  53.             Result:=nil;
  54.           end;
  55. constructor TLangVariable.Create;
  56.           begin
  57.             inherited Create(nil);
  58.             Value:=TVarLangValue.Create(nil);
  59.           end;
  60. destructor  TLangVariable.Destroy;
  61.           begin
  62.             Value.Free;
  63.             inherited Destroy;
  64.           end;
  65. end.
  66.