• ParamsToVariant and VariantToParams


     function ParamsToVariant(Params: TParams; Macro, Compatible: Boolean): Variant;
    var
      I: Integer;
      Tmp: Variant;
    begin
      if (Params.Count = 0) then
        Result := Null
      else begin
        Result := VarArrayCreate([0, Params.Count - 1], varVariant);
        for I := 0 to Params.Count - 1 do
          with Params[I] do
          begin
            if Compatible then
              Tmp := VarArrayOf([Name, Unassigned, Unassigned, Unassigned]) else
              Tmp := VarArrayOf([Name, Unassigned, Unassigned, Unassigned, Macro]);
            Tmp[3 - 2 * ord(Compatible)] := Value;
            Tmp[1 + ord(Compatible)] := Ord(DataType);
            Tmp[2 + ord(Compatible)] := Ord(ParamType);
            Result[I] := Tmp;
          end;
      end;
    end;

    procedure VariantToParams(const VarParams: Variant; Params: TParams; Compatible: Boolean);
    var
      I: Integer;
      Param: TParam;
    begin
      Params.Clear;

      if not VarIsNull(VarParams) then
        for I := 0 to VarArrayHighBound(VarParams, 1) do
        begin
          Param := Params.CreateParam(
            TFieldType(VarParams[I][1 + ord(Compatible)]),
            VarParams[I][0],
            TParamType(VarParams[I][2 + ord(Compatible)]));

          Param.DataType := TFieldType(VarParams[I][1 + ord(Compatible)]);
          if VarIsNull(VarParams[I][3 - 2 * ord(Compatible)]) or VarIsEmpty(VarParams[I][3 - 2 * ord(Compatible)]) then
            Param.Clear else Param.Value := VarParams[I][3 - 2 * ord(Compatible)];
        end;
    end;

  • 相关阅读:
    交叉编译qt5.4.1遇到的错误
    qt5.4.1官网上找不到
    Runtime dependency gstreameraudio1.0 found: NO (tried pkgconfig and cmake)
    gstreamer库 ubuntu下安装
    gstreamer编译错误
    gstreamer在ubuntu上源码编译
    http学习
    SQL定义变量
    对w3wp.exe的一点认识!
    官方发布!DevExpress WPF 2022年产品升级路线图
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940578.html
Copyright © 2020-2023  润新知