Skip to content

Utility Functions

The unit WEBLib.WebTools contains several helper functions that can be handy.

The list of available utility functions is:

procedure MessageBeep(AType: integer);
Method with a VCL compatible signature playing a beep in the browser.
procedure OutputDebugString(const s: string);
Sends the string to the browser event log
function GetTickCount: longint;
Returns the number of ticks since browser start in milliseconds
function GetQueryParam(AName: string): string;
Returns the URL query parameter value for the URL with which the web application was started. Example:

https://www.myserver.com/mysite?user=Admin

with return ‘Admin’ for GetQueryParam(‘user’);

function HasQueryParam(AName: string; var AValue: string): boolean;
Returns true if a specific query parameter is present in the URL with which the application was launched.
function GetLocaleShortDateFormat(ALocale: string = ''): string;
Gets the short date format according to the browser locale
function GetLocaleLongDayName(DayOfWeek: integer; ALocale: string =
''): string;
Gets the long day name for a specific day in the week according to the browser locale
function GetLocaleShortDayName(DayOfWeek: integer; ALocale: string = ''): string;
Gets the short day name for a specific day in the week according to the browser locale
function GetLocaleLongMonthName(Month: integer; ALocale: string = ''): string;
Gets the long month name for a specific day in the week according to the browser locale
function GetLocaleShortMonthName(Month: integer; ALocale: string = ''): string;
Gets the short month name for a specific month in the year according to the browser locale
function GetLocaleDecimalSeparator(ALocale: string = ‘’): string;
Gets the decimal separator character according to the browser locale or the specified locale
function GetLocaleThousandSeparator(ALocale: string = ‘’): string;
Gets the thousand separator character according to the browser locale or the specified locale
function GetLocaleCurrency(ALocale: string = ‘’): string;
Gets the currency according to the browser locale or the specified locale
function LocaleFormatCurrency(Value: double; ACurrency: string; ALocale: string = ''): string;
Formats a value with a currency according to the browser locale or the specified locale
function GetBrowserLocale: string;
Retrieves the browser locale as string. See appendix for possible locale names.
function ProcessAccelerator(AValue: string; var Accelerator: string): string;
Converts a string using accelerator keys (i.e. characters preceeded by &) as underlined HTML text. The Accelerator var parameter is set to the accelerator key value. Example:

My &Button

will be converted to

My <B>utton and the Accelerator var parameter will be set to B

function GetBase64Image(AImage: TJSHTMLElement): string

Retrieves the image data as base64 encoded string

procedure DebugBreak;
Sets a breakpoint in the code at the line where DebugBreak is called.