Official Content

Creates a character text from a given text that may contain parameter markers and the values indicated for the parameters.

Syntax

Format(Str [, <character-expression1>,..., <character-expressionN>])

Where:

Str
  Is a character data type that contains zero or more parameter markers (from 1 to 9) like %1, %2, etc.
  It may be a character expression.
  This content may be translated.

character-expression1,...,character-expression
  List of character expressions separated by commas. They indicate the values to be placed where the parameter markers are sited in Str.

Type Returned:
Character

Scope

Objects: ProcedureTransactionWeb PanelPanel, Data Provider
Generators: .NET, .NET Framework, Java, Apple, Android, Angular

Description

The Format function allows you to create a character text from a given text that may contain parameter markers and the values indicated for the parameters.

If a '%' sign needs to be included in the text, it must be preceded by the '\' (backslash) sign to indicate that it is not a parameter. For example: "This is not a parameter marker: \%1".

Samples

1) In the following example, parameter markers are %1 and %2. They state where, in the resulting string, the values of "Alex" and "26" must be embedded.

Msg(Format("%1 is %2 years old.", "Alex", "26"))

The Msg rule will show the text: "Alex is 26 years old".

2) In the following example, the markers are replaced with attributes, and the result is assigned to a variable:

&Variable=Format("Customer %1 was born in %2", CustomerName, CountryName);

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant