Home > lang > subst 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs ar fa id vi ko ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
Documentation  
Warning! This page is not translated.  See english version 
Subst$
Result = Subst$ ( Pattern , ReplaceString [ , ReplaceString ... ] )
Result = Subst ( Pattern , ReplaceString [ , ReplaceString ... ] )

Replaces substrings &1, &2, etc. in a pattern with the first, second, and subsequent ReplaceString argument respectively, and returns the result.

If Pattern is null, then a null string is returned.

For C developers, this is not unlike a simplified sprintf.

Example

PRINT Subst("Gambas is a cool &1", "BASIC")

Gambas is a cool BASIC

This function is very useful when you must concatenate strings that must be translated. Do not use the & operator, as the order of concatenation may change with the language.

For example:

PRINT Subst(("Today, we are &1 &2"), Format$(Now, "mmm"), Format$(Now, "d"))

will be translated in french this way:

PRINT Subst(("Aujourd'hui, nous sommes le &2 &1"), Format$(Now, "mmm"), Format$(Now, "d"))

See also

String Functions, Localization and Translation Functions