📄 fs_idbrtti.pas
字号:
begin
if MethodName = 'ITEMS.GET' then
Result := Integer(TFieldDefs(Instance)[Caller.Params[0]])
else if MethodName = 'ADD' then
TFieldDefs(Instance).Add(Caller.Params[0], TFieldType(Caller.Params[1]), Caller.Params[2], Caller.Params[3])
else if MethodName = 'ADDFIELDDEF' then
Result := Integer(TFieldDefs(Instance).AddFieldDef)
else if MethodName = 'CLEAR' then
TFieldDefs(Instance).Clear
else if MethodName = 'FIND' then
Result := Integer(TFieldDefs(Instance).Find(Caller.Params[0]))
else if MethodName = 'UPDATE' then
TFieldDefs(Instance).Update
end
else if ClassType = TBlobField then
begin
if MethodName = 'LOADFROMFILE' then
TBlobField(Instance).LoadFromFile(Caller.Params[0])
else if MethodName = 'LOADFROMSTREAM' then
TBlobField(Instance).LoadFromStream(TStream(Integer(Caller.Params[0])))
else if MethodName = 'SAVETOFILE' then
TBlobField(Instance).SaveToFile(Caller.Params[0])
else if MethodName = 'SAVETOSTREAM' then
TBlobField(Instance).SaveToStream(TStream(Integer(Caller.Params[0])))
end
else if ClassType = TDataSet then
begin
_TDataSet := TDataSet(Instance);
if MethodName = 'OPEN' then
_TDataSet.Open
else if MethodName = 'CLOSE' then
_TDataSet.Close
else if MethodName = 'FIRST' then
_TDataSet.First
else if MethodName = 'LAST' then
_TDataSet.Last
else if MethodName = 'NEXT' then
_TDataSet.Next
else if MethodName = 'PRIOR' then
_TDataSet.Prior
else if MethodName = 'CANCEL' then
_TDataSet.Cancel
else if MethodName = 'DELETE' then
_TDataSet.Delete
else if MethodName = 'POST' then
_TDataSet.Post
else if MethodName = 'APPEND' then
_TDataSet.Append
else if MethodName = 'INSERT' then
_TDataSet.Insert
else if MethodName = 'EDIT' then
_TDataSet.Edit
else if MethodName = 'FIELDBYNAME' then
Result := Integer(_TDataSet.FieldByName(Caller.Params[0]))
else if MethodName = 'GETFIELDNAMES' then
_TDataSet.GetFieldNames(TStrings(Integer(Caller.Params[0])))
else if MethodName = 'FINDFIRST' then
Result := _TDataSet.FindFirst
else if MethodName = 'FINDLAST' then
Result := _TDataSet.FindLast
else if MethodName = 'FINDNEXT' then
Result := _TDataSet.FindNext
else if MethodName = 'FINDPRIOR' then
Result := _TDataSet.FindPrior
else if MethodName = 'FREEBOOKMARK' then
_TDataSet.FreeBookmark(TBookMark(Integer(Caller.Params[0])))
else if MethodName = 'GETBOOKMARK' then
Result := Integer(_TDataSet.GetBookmark)
else if MethodName = 'GOTOBOOKMARK' then
_TDataSet.GotoBookmark(TBookMark(Integer(Caller.Params[0])))
else if MethodName = 'LOCATE' then
Result := _TDataSet.Locate(Caller.Params[0], Caller.Params[1], IntToLocateOptions(Caller.Params[2]))
else if MethodName = 'ISEMPTY' then
Result := _TDataSet.IsEmpty
else if MethodName = 'ENABLECONTROLS' then
_TDataSet.EnableControls
else if MethodName = 'DISABLECONTROLS' then
_TDataSet.DisableControls
end
else if ClassType = TParam then
begin
if MethodName = 'CLEAR' then
TParam(Instance).Clear
end
else if ClassType = TParams then
begin
if MethodName = 'PARAMBYNAME' then
Result := Integer(TParams(Instance).ParamByName(Caller.Params[0]))
else if MethodName = 'FINDPARAM' then
Result := Integer(TParams(Instance).FindParam(Caller.Params[0]))
else if MethodName = 'ITEMS.GET' then
Result := Integer(TParams(Instance)[Caller.Params[0]])
end
end;
function TFunctions.GetProp(Instance: TObject; ClassType: TClass;
const PropName: String): Variant;
var
_TField: TField;
_TParam: TParam;
_TDataSet: TDataSet;
function FilterOptionsToInt(f: TFilterOptions): Integer;
begin
Result := 0;
if foCaseInsensitive in f then
Result := Result or 1;
if foNoPartialCompare in f then
Result := Result or 2;
end;
begin
Result := 0;
if ClassType = TField then
begin
_TField := TField(Instance);
if PropName = 'ASBOOLEAN' then
Result := _TField.AsBoolean
else if PropName = 'ASCURRENCY' then
Result := _TField.AsCurrency
else if PropName = 'ASDATETIME' then
Result := _TField.AsDateTime
else if PropName = 'ASFLOAT' then
Result := _TField.AsFloat
else if PropName = 'ASINTEGER' then
Result := _TField.AsInteger
else if PropName = 'ASSTRING' then
Result := _TField.AsString
else if PropName = 'ASVARIANT' then
Result := _TField.AsVariant
else if PropName = 'DATATYPE' then
Result := _TField.DataType
else if PropName = 'DISPLAYNAME' then
Result := _TField.DisplayName
else if PropName = 'DISPLAYTEXT' then
Result := _TField.DisplayText
else if PropName = 'ISNULL' then
Result := _TField.IsNull
else if PropName = 'SIZE' then
Result := _TField.Size
else if PropName = 'VALUE' then
Result := _TField.Value
else if PropName = 'OLDVALUE' then
Result := _TField.OldValue
end
else if ClassType = TDataSet then
begin
_TDataSet := TDataSet(Instance);
if PropName = 'BOF' then
Result := _TDataSet.Bof
else if PropName = 'EOF' then
Result := _TDataSet.Eof
else if PropName = 'FIELDCOUNT' then
Result := _TDataSet.FieldCount
else if PropName = 'FIELDDEFS' then
Result := Integer(_TDataSet.FieldDefs)
else if PropName = 'FIELDS' then
Result := Integer(_TDataSet.Fields)
else if PropName = 'FILTER' then
Result := _TDataSet.Filter
else if PropName = 'FILTERED' then
Result := _TDataSet.Filtered
else if PropName = 'FILTEROPTIONS' then
Result := FilterOptionsToInt(_TDataSet.FilterOptions)
else if PropName = 'ACTIVE' then
Result := _TDataSet.Active
end
else if ClassType = TParam then
begin
_TParam := TParam(Instance);
if PropName = 'BOUND' then
Result := _TParam.Bound
else if PropName = 'ISNULL' then
Result := _TParam.IsNull
else if PropName = 'TEXT' then
Result := _TParam.Text
else if PropName = 'ASBOOLEAN' then
Result := _TParam.AsBoolean
else if PropName = 'ASCURRENCY' then
Result := _TParam.AsCurrency
else if PropName = 'ASDATETIME' then
Result := _TParam.AsDateTime
else if PropName = 'ASFLOAT' then
Result := _TParam.AsFloat
else if PropName = 'ASINTEGER' then
Result := _TParam.AsInteger
else if PropName = 'ASDATE' then
Result := _TParam.AsDate
else if PropName = 'ASTIME' then
Result := _TParam.AsTime
else if PropName = 'ASSTRING' then
Result := _TParam.AsString
end
end;
procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass;
const PropName: String; Value: Variant);
var
_TField: TField;
_TParam: TParam;
_TDataSet: TDataSet;
function IntToFilterOptions(i: Integer): TFilterOptions;
begin
Result := [];
if (i and 1) <> 0 then
Result := Result + [foCaseInsensitive];
if (i and 2) <> 0 then
Result := Result + [foNoPartialCompare];
end;
begin
if ClassType = TField then
begin
_TField := TField(Instance);
if PropName = 'ASBOOLEAN' then
_TField.AsBoolean := Value
else if PropName = 'ASCURRENCY' then
_TField.AsCurrency := Value
else if PropName = 'ASDATETIME' then
_TField.AsDateTime := Value
else if PropName = 'ASFLOAT' then
_TField.AsFloat := Value
else if PropName = 'ASINTEGER' then
_TField.AsInteger := Value
else if PropName = 'ASSTRING' then
_TField.AsString := Value
else if PropName = 'ASVARIANT' then
_TField.AsVariant := Value
else if PropName = 'VALUE' then
_TField.Value := Value
else if PropName = 'SIZE' then
_TField.Size := Value
end
else if ClassType = TDataSet then
begin
_TDataSet := TDataSet(Instance);
if PropName = 'FILTER' then
_TDataSet.Filter := Value
else if PropName = 'FILTERED' then
_TDataSet.Filtered := Value
else if PropName = 'FILTEROPTIONS' then
_TDataSet.FilterOptions := IntToFilterOptions(Value)
else if PropName = 'ACTIVE' then
_TDataSet.Active := Value
end
else if ClassType = TParam then
begin
_TParam := TParam(Instance);
if PropName = 'ASBOOLEAN' then
_TParam.AsBoolean := Value
else if PropName = 'ASCURRENCY' then
_TParam.AsCurrency := Value
else if PropName = 'ASDATETIME' then
_TParam.AsDateTime := Value
else if PropName = 'ASFLOAT' then
_TParam.AsFloat := Value
else if PropName = 'ASINTEGER' then
_TParam.AsInteger := Value
else if PropName = 'ASDATE' then
_TParam.AsDate := Value
else if PropName = 'ASTIME' then
_TParam.AsTime := Value
else if PropName = 'ASSTRING' then
_TParam.AsString := Value
else if PropName = 'BOUND' then
_TParam.Bound := Value
else if PropName = 'TEXT' then
_TParam.Text := Value
end
end;
initialization
fsRTTIModules.Add(TFunctions);
finalization
if fsRTTIModules <> nil then
fsRTTIModules.Remove(TFunctions);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -