The following functions are built-in HelpNDoc's script engine and can be used in scripts and templates.

String related functions

Function

Description

Chr(i: Integer): Char;

Returns the character for a specified ASCII value.

DupeString(str: string; count: Integer): string;

Returns the concatenation of a string with itself a specified number of repeats.

IntToStr(i: Integer): string;

Converts an integer to a string.

StrToInt(str: string): Integer;

Converts a string that represents an integer into a number.

StrToIntDef(str: string; def: Integer): Integer;

Converts a string that represents an integer into a number with error default.

IntToHex(v: Integer; digits: Integer): string;

Returns the hexadecimal representation of an ordinal number. 

HexToInt(hexa: string): Integer;

Returns the integer value of an hexadecimal representation.

BoolToStr(b: Boolean): string;

Converts a Boolean value into a string. 

StrToBool(str: string): Boolean;

Converts a string to a Boolean value. 

FloatToStr(f: Float): string;

Converts a floating-point value to a string. 

StrToFloat(str: string): Float;

Converts a given string to a floating-point value. 

StrToFloatDef(str: string; def: Float): Float;

Converts a given string into a floating-point value, with a default error. 

Format(fmt: string; args array of const): string;

Returns a formatted string assembled from a format string and an array of arguments. 

The following table summarizes the possible values for type:

  • d - Decimal. The argument must be an integer value. The value is converted to a string of decimal digits;
  • u - Unsigned decimal. Similar to d, but no sign is output;
  • e - Scientific. The argument must be a floating-point value. The value is converted to a string of the form "-d.ddd...E+ddd";
  • f - Fixed. The argument must be a floating-point value. The value is converted to a string of the form "-ddd.ddd...";
  • g - General. The argument must be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format;
  • n - Number. The argument must be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The n format corresponds to the f format, except that the resulting string contains thousand separators;
  • m - Money. The argument must be a floating-point value;
  • s - String. The argument must be a character, or a string;
  • x - Hexadecimal. The argument must be an integer value.

To display the character % (that is, to display a literal %, not to begin a format specifier), use the sequence %%. Example: 
Format('%d%%', [50]); // Displays 50%

LowerCase(str: string): string;

Converts a string to lowercase. 

UpperCase(str: string): string;

Converts a string to uppercase. 

PadLeft(str: string; count: Integer; char: Char = ' '): string;

Left-aligns a string into a fixed length text using the character specified.

PadRight(str: string; count: Integer; char: Char = ' '): string;

Right-aligns a string into a fixed length text using the character specified.

Pos(needle: string; haystack: string): Integer;
Pos(needle: string; haystack: string; offset: Integer): Integer;

Locates a substring in a given string. Start at offset if specified.

ReverseString(str: string): string;

Returns the reverse of a specified string.

SameText(str1: string; str2: string): Boolean;

Compares two strings by ordinal value without case sensitivity. 

StringOfChar(ch: Char; count: Integer): string;

Returns a string with a specified number of repeating characters.

SubStr(str: string; start: Integer; Length: Integer = MaxInt): string;

Returns a specified substring the specified string.

TrimLeft(str: string): string;

Removes blank and control characters from the left side of a string.

TrimRight(str: string): string;

Removes blank and control characters from the right side of a string. 

Trim(str: string): string;

Removes blank and control characters from both sides of a string.