开放式数组参数,我学习

KeyLife富翁笔记
作者: HongYuan
标题: 开放式数组参数,我学习
关键字: 动态数组,开放式数组参数
分类: 个人专区
密级: 公开
(评分: , 回复: 0, 阅读: 603) »»

指定类型,但不确定元素个数的开放式数组参数
Type
  arrayChar = array char;
procedure test(const args:arrayChar);
var
  i:integer
begin
  for i:=low(args) to high(args) do //setlength(args,x)
  ......
end;

不确定参数类型,不确定元素个数的开放式数组参数
function test(var Args: array of const): string;
var
  I: Integer;
begin
  Result := '';
  for I := 0 to High(Args) do
    with Args[I] do
      case VType of
        vtInteger:    Result := Result + IntToStr(VInteger);
        vtBoolean:    Result := Result + BoolToStr(VBoolean);
        vtChar:       Result := Result + VChar;
        vtExtended:   Result := Result + FloatToStr(VExtended^);

        vtString:     Result := Result + VString^;
        vtPChar:      Result := Result + VPChar;
        vtObject:     Result := Result + VObject.ClassName;
        vtClass:      Result := Result + VClass.ClassName;
        vtAnsiString: Result := Result + string(VAnsiString);
        vtCurrency:   Result := Result + CurrToStr(VCurrency^);
        vtVariant:    Result := Result + string(VVariant^);
        vtInt64:      Result := Result + IntToStr(VInt64^);

    end;
end;


2005-9-15 15:02:08   
原文地址:https://www.cnblogs.com/ZhouXiHong/p/568276.html