两个Procedure

来源:互联网 发布:php 空白页面 编辑:程序博客网 时间:2024/04/28 21:34

1:

Exclude procedure:
Removes an element from a set.
Delphi syntax:

procedure Exclude(var S: set of T;I:T);

Description

In Delphi, the Exclude procedure removes element I from set S.

S is a set type variable, and I is an expression of a type compatible with the base type of S.

The construct Exclude (S, I) corresponds to S := S - (I) but the Exclude procedure generates more efficient code.

2:

Inc procedure:

Increments an ordinal value by one or N.
Delphi syntax:

procedure Inc(var X [ ; N: Longint ] );

Description

In Delphi code, Inc adds one or N to the variable X.

X is a variable of an ordinal type (including Int64), or a pointer type if the extended syntax is enabled.

N is an integer-type expression.

X increments by 1, or by N if N is specified; that is, Inc(X) corresponds to the statement X := X + 1, and Inc(X, N) corresponds to the statement X := X + N. However, Inc generates optimized code and is especially useful in tight loops.

Note: If X is a pointer type, it increments X by N times the size of the type pointed to. Thus, given

type

  PMytype = ^TMyType;

and

var

  P: PMyType;

the statement

Inc(P);

increments P by SizeOf(TMyType).

Warning: You can’t use Inc on properties because it modifies the parameter.

Note: Inc(S, I) where S is a ShortInt and I is a number greater than 127 will cause an EIntOverFlow exception to be raised if range and overflow checking are on. In Delphi 1.0, this did not raise an exception.

原创粉丝点击