我有两种 arapper 类型可以轻松处理/返回一维数组,我想编写一个方法来将一个转换为另一个(一个 2d-float-Vector 类到一个 2d-int-point 类)。写了一个简单的,但它只是抛出一些我不明白的错误。
unit UUtil;
interface
uses
UVector2f, Types, SysUtils;
type
Vector2fArrayWrapper = array of Vector2f;
PointArrayWrapper = array of TPoint;
implementation
function toPointArray(vw : Vector2fArrayWrapper) : PointArrayWrapper;
var pw : PointArrayWrapper;
i,x,y : Integer;
begin
setLength(pw, vw.length);
for i := 0 to vw.high do
begin
x := round(vw[i].getX());
y := round(vw[i].getY());
vw[i] := TPoint(x,y);
end;
result := pw;
end;
end.
这些是我得到的错误:
[Error] UUtil.pas(20): Record, object or class type required
[Error] UUtil.pas(21): Record, object or class type required
[Error] UUtil.pas(25): ')' expected but ',' found
[Error] UUtil.pas(27): Declaration expected but identifier 'result' found
[Error] UUtil.pas(28): '.' expected but ';' found