-
Declaration:
- Function NewStr (Const S: String): PString;
-
Description:
- NewStr makes a copy of the string S on the heap, and returns a pointer to this copy.
The allocated memory is not based on the declared size of the string passed to NewStr, but
is baed on the actual length of the string.
-
Errors:
- If not enough memory is available, an ’out of memory’ error will occur.
-
See also:
- DisposeStr (548)
Listing: objectex/ex40.pp
-
Declaration:
- Procedure DisposeStr (P: PString);
-
Description:
- DisposeStr removes a dynamically allocated string from the heap.
-
Errors:
- None.
-
See also:
- NewStr (548)
For an example, see NewStr (548).
-
Declaration:
- Procedure Abstract;
-
Description:
- When implementing abstract methods, do not declare them as abstract. Instead, define
them simply as virtual. In the implementation of such abstract methods, call the Abstract
procedure. This allows explicit control of what happens when an abstract method is called.
The current implementation of Abstract terminates the program with a run-time error 211.
-
Errors:
- None.
-
See also:
- Most abstract types.
-
Declaration:
- Procedure RegisterObjects;
-
Description:
- RegisterObjects registers the following objects for streaming:
- TCollection, see section 17.10, page 592.
- TStringCollection, see section 17.12, page 619.
- TStrCollection, see section 17.13, page 623.
-
Errors:
- None.
-
See also:
- RegisterType (549)
-
Declaration:
- Procedure RegisterType (Var S: TStreamRec);
-
Description:
- RegisterType registers a new type for streaming. An object cannot be streamed unless it
has been registered first. The stream record S needs to have the following fields set:
-
ObjType: Sw__Word
- This should be a unique identifier. Each possible type should have
it’s own identifier.
-
VmtLink: pointer
- This should contain a pointer to the VMT (Virtual Method Table) of the
object you try to register. You can get it with the following expression:
VmtLink: Ofs(TypeOf(MyType)^);
|
-
Load : Pointer
- is a pointer to a method that initializes an instance of that object, and reads the
initial values from a stream. This method should accept as it’s sole argument a PStream type
variable.
-
Store: Pointer
- is a pointer to a method that stores an instance of the object to a stream. This
method should accept as it’s sole argument a PStream type variable.
-
Errors:
- In case of error (if a object with the same ObjType) is already registered), run-time error 212
occurs.
Listing: objectex/myobject.pp
-
Declaration:
- Function LongMul (X, Y: Integer): LongInt;
-
Description:
- LongMul multiplies X with Y. The result is of type Longint. This avoids possible overflow
errors you would normally get when multiplying X and Y that are too big.
-
Errors:
- None.
-
See also:
- LongDiv (553)
-
Declaration:
- Function LongDiv (X: Longint; Y: Integer): Integer;
-
Description:
- LongDiv divides X by Y. The result is of type Integer instead of type Longint, as you
would get normally.
-
Errors:
- If Y is zero, a run-time error will be generated.
-
See also:
- LongMul (552)