⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_isysrtti.pas

📁 报表源码 FastReport 3 is new generation of the report generators components. It consists of report engin
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    AddConst('varString', 'Integer', $0100);
    AddConst('varAny', 'Integer', $0101);
    AddConst('varTypeMask', 'Integer', $0FFF);
    AddConst('varArray', 'Integer', $2000);
    AddConst('varByRef', 'Integer', $4000);
    
    AddedBy := nil;
  end;
end;

destructor TFunctions.Destroy;
begin
  if fsGlobalUnit <> nil then
    fsGlobalUnit.RemoveItems(Self);
  inherited;
end;

function TFunctions.CallMethod1(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
var
{$IFDEF Delphi6}
  i: Int64;
{$ELSE}
  i: Integer;
{$ENDIF}
begin
  if MethodName = 'INTTOSTR' then
  begin
    i := Params[0];
    Result := IntToStr(i)
  end
  else if MethodName = 'FLOATTOSTR' then
    Result := FloatToStr(Params[0])
  else if MethodName = 'DATETOSTR' then
    Result := DateToStr(Params[0])
  else if MethodName = 'TIMETOSTR' then
    Result := TimeToStr(Params[0])
  else if MethodName = 'DATETIMETOSTR' then
    Result := DateTimeToStr(Params[0])
end;

function TFunctions.CallMethod2(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
begin
  if MethodName = 'STRTOINT' then
    Result := StrToInt(Params[0])
  else if MethodName = 'STRTOFLOAT' then
    Result := StrToFloat(Params[0])
  else if MethodName = 'STRTODATE' then
    Result := StrToDate(Params[0])
  else if MethodName = 'STRTOTIME' then
    Result := StrToTime(Params[0])
  else if MethodName = 'STRTODATETIME' then
    Result := StrToDateTime(Params[0])
end;

function TFunctions.CallMethod3(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
begin
  if MethodName = 'FORMAT' then
    Result := FormatV(Params[0], Params[1])
  else if MethodName = 'FORMATFLOAT' then
    Result := FormatFloat(Params[0], Params[1])
  else if MethodName = 'FORMATDATETIME' then
    Result := FormatDateTime(Params[0], Params[1])
  else if MethodName = 'FORMATMASKTEXT' then
    Result := FormatMaskText(Params[0], Params[1])
end;

function TFunctions.CallMethod4(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
var
  w1, w2, w3, w4: Word;
begin
  if MethodName = 'ENCODEDATE' then
    Result := EncodeDate(Params[0], Params[1], Params[2])
  else if MethodName = 'ENCODETIME' then
    Result := EncodeTime(Params[0], Params[1], Params[2], Params[3])
  else if MethodName = 'DECODEDATE' then
  begin
    DecodeDate(Params[0], w1, w2, w3);
    Params[1] := w1;
    Params[2] := w2;
    Params[3] := w3;
  end
  else if MethodName = 'DECODETIME' then
  begin
    DecodeTime(Params[0], w1, w2, w3, w4);
    Params[1] := w1;
    Params[2] := w2;
    Params[3] := w3;
    Params[4] := w4;
  end
  else if MethodName = 'DATE' then
    Result := Date
  else if MethodName = 'TIME' then
    Result := Time
  else if MethodName = 'NOW' then
    Result := Now
  else if MethodName = 'DAYOFWEEK' then
    Result := DayOfWeek(Params[0])
  else if MethodName = 'ISLEAPYEAR' then
    Result := IsLeapYear(Params[0])
  else if MethodName = 'DAYSINMONTH' then
    Result := DaysInMonth(Params[0], Params[1])
end;

function TFunctions.CallMethod5(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
var
  s: String;
  v: Variant;
begin
  if MethodName = 'LENGTH' then
  begin
    v := Params[0];
    if VarIsArray(v) then
      Result := VarArrayHighBound(v, 1) - VarArrayLowBound(v, 1) + 1
    else
      Result := Length(v)
  end
  else if MethodName = 'COPY' then
    Result := Copy(Params[0], Integer(Params[1]), Integer(Params[2]))
  else if MethodName = 'POS' then
    Result := Pos(Params[0], Params[1])
  else if MethodName = 'DELETE' then
  begin
    s := Params[0];
    Delete(s, Integer(Params[1]), Integer(Params[2]));
    Params[0] := s;
  end
  else if MethodName = 'INSERT' then
  begin
    s := Params[1];
    Insert(Params[0], s, Integer(Params[2]));
    Params[1] := s;
  end
  else if MethodName = 'UPPERCASE' then
    Result := AnsiUppercase(Params[0])
  else if MethodName = 'LOWERCASE' then
    Result := AnsiLowercase(Params[0])
  else if MethodName = 'TRIM' then
    Result := Trim(Params[0])
  else if MethodName = 'NAMECASE' then
    Result := NameCase(Params[0])
  else if MethodName = 'COMPARETEXT' then
    Result := AnsiCompareText(Params[0], Params[1])
  else if MethodName = 'CHR' then
    Result := Chr(Integer(Params[0]))
  else if MethodName = 'ORD' then
    Result := Ord(String(Params[0])[1])
  else if MethodName = 'SETLENGTH' then
  begin
    if (TVarData(Params[0]).VType = varString) or
      (TVarData(Params[0]).VType = varOleStr) then
    begin
      s := Params[0];
      SetLength(s, Integer(Params[1]));
      Params[0] := s;
    end
    else
    begin
      v := Params[0];
      VarArrayRedim(v, Integer(Params[1]) - 1);
      Params[0] := v;
    end;
  end
end;

function TFunctions.CallMethod6(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
begin
  if MethodName = 'ROUND' then
    Result := Integer(Round(Params[0]))
  else if MethodName = 'TRUNC' then
    Result := Integer(Trunc(Params[0]))
  else if MethodName = 'INT' then
    Result := Int(Params[0])
  else if MethodName = 'FRAC' then
    Result := Frac(Params[0])
  else if MethodName = 'SQRT' then
    Result := Sqrt(Params[0])
  else if MethodName = 'ABS' then
    Result := Abs(Params[0])
  else if MethodName = 'SIN' then
    Result := Sin(Params[0])
  else if MethodName = 'COS' then
    Result := Cos(Params[0])
  else if MethodName = 'ARCTAN' then
    Result := ArcTan(Params[0])
  else if MethodName = 'TAN' then
    Result := Sin(Params[0]) / Cos(Params[0])
  else if MethodName = 'EXP' then
    Result := Exp(Params[0])
  else if MethodName = 'LN' then
    Result := Ln(Params[0])
  else if MethodName = 'PI' then
    Result := Pi
end;

function TFunctions.CallMethod7(Instance: TObject; ClassType: TClass;
  const MethodName: String; var Params: Variant): Variant;
begin
  if MethodName = 'INC' then
  begin
    Params[0] := Params[0] + Params[1];
  end
  else if MethodName = 'DEC' then
  begin
    Params[0] := Params[0] - Params[1];
  end
  else if MethodName = 'RAISEEXCEPTION' then
    raise Exception.Create(Params[0])
{$IFNDEF NOFORMS}
  else if MethodName = 'SHOWMESSAGE' then
    ShowMessage(Params[0])
{$ENDIF}
  else if MethodName = 'RANDOMIZE' then
    Randomize
  else if MethodName = 'RANDOM' then
    Result := Random
  else if MethodName = 'VALIDINT' then
    Result := ValidInt(Params[0])
  else if MethodName = 'VALIDFLOAT' then
    Result := ValidFloat(Params[0])
  else if MethodName = 'VALIDDATE' then
    Result := ValidDate(Params[0])
{$IFDEF OLE}
  else if MethodName = 'CREATEOLEOBJECT' then
    Result := CreateOleObject(Params[0])
{$ENDIF}
  else if MethodName = 'VARARRAYCREATE' then
    Result := VArrayCreate(Params[0], Params[1])
  else if MethodName = 'VARTOSTR' then
    Result := VarToStr(Params[0])
  else if MethodName = 'VARTYPE' then
    Result := VarType(Params[0])
end;


initialization
  Functions := TFunctions.Create;

finalization
  Functions.Free;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -