【问题标题】:Array type required in DelphiDelphi中需要的数组类型
【发布时间】:2021-12-10 15:00:30
【问题描述】:

我在Delphi上重建旧项目,在properties中将对象的位置作为向量传递,然后写入到对应的PosX属性中,以此类推,这就是莫名其妙的错误“Array type required “出现。我在网上没有发现这样的错误。 需要什么类型,在哪里需要?

private
     { Private Properties }
     FPosition  : TVector;
     FDirection, FUp : TVector;
public
     property Position : TVector read FPosition write FPosition;
     property PosX : Single read FPosition[0]  write FPosition[0];
     property PosY : Single read FPosition[1] write FPosition[1];
     property PosZ : Single read FPosition[2] write FPosition[2];

错误附加在向量每个元素的“]”字符上

更新:

版本 Delphi 10.4。 我在以“property PosX”开头的每一行有 2 个错误,总共有 6 个错误 Image

我找到了类型是如何声明的:

TVector = record
  case Integer of
    0: (V: array[0..3]} of Single);
    1: (X,Y,Z,W : Single);
end;

【问题讨论】:

标签: delphi vector


【解决方案1】:

通过将 FPosition [0] 替换为 FPosition.X 解决了问题

     property Position : TVector read FPosition write FPosition;
     property PosX : Single read FPosition.X write FPosition.X;
     property PosY : Single read FPosition.Y write FPosition.Y;
     property PosZ : Single read FPosition.Z write FPosition.Z;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 2015-08-26
    • 2011-06-27
    • 1970-01-01
    • 2015-02-07
    相关资源
    最近更新 更多