我查了一下它的DELPHI英文帮助:
Delphi syntax:function Assigned(const P): Boolean;DescriptionUse Assigned to determine whether the pointer or procedure referenced by P is nil. P must be a variable reference of a pointer or procedural type. Assigned(P) corresponds to the test P<> nil for a pointer variable, and @P <> nil for a procedural variable.Assigned returns false if P is nil, true otherwise.Note: Assigned can't detect a dangling pointer--that is, one that isn't nil but no longer points to valid data. For example, in the code example for Assigned, Assigned won't detect the fact that P isn't valid.
它说这个方法是用来决定指针或过程的引用P是否为NIL。
我不是很明白这句话的意思,除了对象之外,这个函数还能用于var定义的普通变量吗?
如果您很清楚这个函数的用法,麻烦帮我列一下它可能的参数/
Delphi syntax:function Assigned(const P): Boolean;DescriptionUse Assigned to determine whether the pointer or procedure referenced by P is nil. P must be a variable reference of a pointer or procedural type. Assigned(P) corresponds to the test P<> nil for a pointer variable, and @P <> nil for a procedural variable.Assigned returns false if P is nil, true otherwise.Note: Assigned can't detect a dangling pointer--that is, one that isn't nil but no longer points to valid data. For example, in the code example for Assigned, Assigned won't detect the fact that P isn't valid.
它说这个方法是用来决定指针或过程的引用P是否为NIL。
我不是很明白这句话的意思,除了对象之外,这个函数还能用于var定义的普通变量吗?
如果您很清楚这个函数的用法,麻烦帮我列一下它可能的参数/
区别在于Assigned参数可以带一个函数或方法指针
可以这样:
var
A: procedure;
begin
A := nil;
if Assigned(A) then // A不会被当成函数
begin
end;
end;但不能这样:
var
A: procedure;
begin
A := nil;
if A <> nil then // A会被当成函数执行!
begin
end;
end;
在我看来这就是他们唯一的区别,其他都一样。Assigned这类函数叫编译器函数,语法上是声明不了的。
类似还有Str、Val、Write、Read等。
语法就是死规矩,记住就行了。
没什么好深入研究的。