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

  1. unit InputQueryProc;
  2.  
  3. interface
  4. uses LangValue,
  5.      VarLangValue,Dialogs;
  6. type TInputQueryProc=class(ILangValue)
  7.         procedure Exec(S:IValStack;MustReturn:boolean);override;
  8.      end;
  9. implementation
  10. procedure TInputQueryProc.Exec;
  11.           Var sCaption,sPrompt,sValue:string;
  12.               aResult:boolean;
  13.               iCaption,iPrompt,iValue:integer;
  14.               vCaption,vPrompt,vValueRef,vValue,vResult:ILangValue;
  15.           begin
  16.             sCaption:='';
  17.             sPrompt:='';
  18.             sValue:='';
  19.             vValueRef:=nil;
  20.             iCaption:=-1;
  21.             iPrompt:=-1;
  22.             iValue:=-1;
  23.             case s.FrameCount of
  24.               1:begin
  25.                   iValue:=0;
  26.                 end;
  27.               2:begin
  28.                   iPrompt:=0;
  29.                   iValue:=1;
  30.                 end;
  31.               3:begin
  32.                   iCaption:=0;
  33.                   iPrompt:=1;
  34.                   iValue:=2;
  35.                 end;
  36.             end;
  37.             if iValue<>-1 then
  38.             begin
  39.               vValueRef:=s.FrameValues[iValue].CreateEqu;
  40.               vValue:=vValueRef.GetValue;
  41.               sValue:=vValue.AsString;
  42.               vValue.Free;
  43.             end;
  44.             if iPrompt<>-1 then
  45.             begin
  46.               sPrompt:=s.FrameValues[iPrompt].AsString;
  47.             end;
  48.             if iCaption<>-1 then
  49.             begin
  50.               sCaption:=s.FrameValues[iCaption].AsString;
  51.             end;
  52.             s.DropFrame;
  53.             aResult:=InputQuery(sCaption,sPrompt,sValue);
  54.             if iValue<>-1 then
  55.             begin
  56.               vValue:=TVarLangValue.Create(nil);
  57.               vValue.AsString:=sValue;
  58.               vValueRef.SetValue(vValue);
  59.               vValueRef.Free;
  60.             end;
  61.             if MustReturn then
  62.             begin
  63.               vResult:=TVarLangValue.Create(nil);
  64.               vResult.AsBoolean:=aResult;
  65.               s.Push(vResult);
  66.             end;
  67.           end;
  68.  
  69. end.
  70.