Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

Helper Routines

Project: Console Application Runner Classes

Unit: PJConsoleApp

Applies to: ~>3.0

The following routines are declared in the library:

IsApplicationError

function IsApplicationError(const ErrCode: LongWord): Boolean;

IsApplicationError description

Checks if error code ErrCode is an application defined error. Returns True if the error is application defined, False if not.

IsApplicationError remarks

Application defined error codes have bit 29 set per Windows recommendations.

Use this routine to test error codes that are stored in the ErrorCode property of TPJCustomConsoleApp.

MakeConsoleColors

function MakeConsoleColors(const AForeground, ABackground: TPJConsoleColor):
  TPJConsoleColors; overload;

function MakeConsoleColors(const AForeground, ABackground: TColor):
  TPJConsoleColors; overload;

function MakeConsoleColors(const AForeground, ABackground: TAlphaColor):
  TPJConsoleColors; overload;

MakeConsoleColors description

Three overloaded “constructor” functions, each of which creates an initialised TPJConsoleColors record from the foreground and background colours specified by the AForeground and ABackground parameters.

The first of the routines with the TPJConsoleColor parameters assigns the parameters directly to the fields of the TPJConsoleColors record.

The second of the routines with the TColor parameters first converts the TColor values to the equivalent TPJConsoleColor before assigning the resulting record’s fields. This function is provided as a convenience to enable uses to initialise a TPJConsoleColors record directly from TColor values without having to convert to a TPJConsoleColor value manually.

The third, TAlphaColor, overload. This function is similar to the TColor override above, except that it converts TAlphaColor values to the equivalent TPJConsoleColor value.

The TAlphaColor overload is available only when compiling with Delphi XE2 or later.

These functions are provided because it is not possible to assign the fields of the TPJConsoleApp.ConsoleColors property individually. Instead assign the return value of one of these functions to the property.

An exception is raised if either the TColor or TAlphaColor versions of the routine is passed any colour value that is not one of the 16 standard colours that correspond to the colours in the TPJConsoleColor enumeration.

MakeSize

function MakeSize(const ACX, ACY: LongInt): TSize;

MakeSize description

This is a “constructor” function that creates initialised TSize records.

This function is provided because if is not possible to assign the fields of properties of type TSize individually. Instead assign the return value of this function to such properties.