Real Types

A real type defines a set of numbers that can be represented with floating-point notation. The table below gives the ranges and storage formats for the fundamental real types on the Win32 platform. Double -5.0 x 10A324 1.7 x 10A308 1516 8 Double -5.0 x 10A324 1.7 x 10A308 1516 8 Currency -922337203685477.5808 922337203685477.5807 1920 8 Currency -922337203685477.5808 922337203685477.5807 1920 8 The following table shows how the fundamental real types map to .NET framework types. Fundamental...

Control Loops

Loops allow you to execute a sequence of statements repeatedly, using a control condition or variable to determine when the execution stops. Delphi has three kinds of control loop repeat statements, while statements, and for statements. You can use the standard Break and Continue procedures to control the flow of a repeat, while, or for statement. Break terminates the statement in which it occurs, while Continue begins executing the next iteration of the sequence. The syntax of a repeat...

Instruction Opcodes

The built-in assembler supports all of the Intel-documented opcodes for general application use. Note that operating system privileged instructions may not be supported. Specifically, the following families of instructions are supported Pentium family Pentium Pro and Pentium II Pentium III Pentium 4 In addition, the built-in assembler supports the following instruction sets AMD 3DNow (from the AMD K6 onwards) AMD Enhanced 3DNow (from the AMD Athlon onwards) For a complete description of each...

Text File Device Drivers

You can define your own text file device drivers for your programs. A text file device driver is a set of four functions that completely implement an interface between Delphi's file system and some device. The four functions that define each device driver are Open, InOut, Flush, and Close. The function header of each function is function DeviceFunc(var F TTextRec) Integer where DeviceFunc is the name of the function (that is, Open, InOut, Flush, or Close). The return value of a deviceinterface...

Using the inline Directive

The Delphi compiler allows functions and procedures to be tagged with the inline directive to improve performance. If the function or procedure meets certain criteria, the compiler will insert code directly, rather than generating a call. Inlining is a performance optimization that can result in faster code, but at the expense of space. Inlining always causes the compiler to produce a larger binary file. The inline directive is used in function and procedure declarations and definitions, like...

Automation Object Method Call Syntax

The syntax of an Automation object method call or property access is similar to that of a normal method call or property access. Automation method calls, however, can use both positional and named parameters. But some Automation servers do not support named parameters. A positional parameter is simply an expression. A named parameter consists of a parameter identifier, followed by the symbol, followed by an expression. Positional parameters must precede any named parameters in a method call....

Open Array Constructors

Open array constructors allow you to construct arrays directly within function and procedure calls. They can be passed only as open array parameters or variant open array parameters. An open array constructor, like a set constructor, is a sequence of expressions separated by commas and enclosed in brackets. you could call the Add procedure with the statement Open array constructors can be passed only as value or const parameters. The expressions in a constructor must be assignment-compatible...

Variant Type Conversions

All integer, real, string, character, and Boolean types are assignment-compatible with Variant. Expressions can be explicitly cast as variants, and the VarAsType and VarCast standard routines can be used to change the internal representation of a variant. The following code demonstrates the use of variants and some of the automatic conversions performed when variants are mixed with other types. The compiler performs type conversions according to the following rules. converts to string...

Short String Types

A string occupies as many bytes as its maximum length plus one. The first byte contains the current dynamic length of the string, and the following bytes contain the characters of the string. The length byte and the characters are considered unsigned values. Maximum string length is 255 characters plus a length byte string 255 . Note On the .NET platform, the short string type is implemented as an array of unsigned bytes. Long String Types A long string variable occupies four bytes of memory...

Operator Precedence

In complex expressions, rules of precedence determine the order in which operations are performed. Precedence of operators , , div, mod, and, shl, shr, as second , lt gt , lt , gt , lt , gt , in, is fourth lowest An operator with higher precedence is evaluated before an operator with lower precedence, while operators of equal precedence associate to the left. Hence the expression multiplies y times z, then adds X to the result is performed first, because is has a higher precedence than . But...

Declaring and Accessing Nested Classes

The following examples demonstrate how to declare and access fields and methods of a nested class. myInnerField Integer procedure innerProc end To implement the innerProc method of the inner class, you must qualify its name with the name of the outer class. For example procedure TOuterClass.TInnerClass.innerProc begin To access the members of the nested type, use dotted notation as with regular class member access. For example x TOuterClass y TOuterClass.TInnerClass x TOuterClass.Create...

Calling Conventions

When you declare a procedure or function, you can specify a calling convention using one of the directives register, pascal, cdecl, stdcall, and safecall. For example, function MyFunction X, Y Real Real cdecl Calling conventions determine the order in which parameters are passed to the routine. They also affect the removal of parameters from the stack, the use of registers for passing parameters, and error and exception handling. The default calling convention is register. The register and...

Forward Declarations and Mutually Dependent Classes

If the declaration of a class type ends with the word class and a semicolon - that is, if it has the form type className class with no ancestor or class members listed after the word class, then it is a forward declaration. A forward declaration must be resolved by a defining declaration of the same class within the same type declaration section. In other words, between a forward declaration and its defining declaration, nothing can occur except other type declarations. Forward declarations...

Compiling Packages

Packages are ordinarily compiled from the IDE using .dpk files generated by the Project Manager. You can also compile .dpk files directly from the command line. When you build a project that contains a package, the package is implicitly recompiled, if necessary. The following table lists the files produced by the successful compilation of a package. Compiled package files File extension Contents DCP Win32 or DCPIL .NET A binary image containing a package header and the concatenation of all .dcu...