sFormatString (client-side)

Use this routine to insert arguments into a string in a manner similar to that used by the C++ printf function. It is useful for formatting strings in a way that is much easier to localize than some other hard-coded methods.

Definition

sFormatString(sFormat,

              aArgs)

Parameters

sFormat

A string containing a combination of text and sequentially-numbered variables in the format %1, %2, and so forth. These variables are replaced with the elements from the corresponding positions in the aArgs array.

aArgs

An array of strings to be inserted into the string specified by the sFormat parameter, in the positions of the sequentially-numbered variables. Any extra arguments are ignored, and any extra variables in the string remain unchanged.

Return Value

A string containing the contents of the sFormat parameter with the appropriate substitutions performed.

Remarks

The following example shows how the string "A and B" is returned and assigned to the variable sFormattedString:

sFormattedString = sFormatString("%1 and %2", Array("A", "B"))

The returned string can easily be changed to "B and A" by changing the format string to "%2 and %1" (without changing the array).

This routine is only available after the taskbar has been inserted by calling either InsertTaskBar or InsertEditTaskBar.

This routine is available in the include file ActionPageUtil.asp.

There is a functionally equivalent version of this routine defined for server-side use in the file ASPUtil.asp.

See Also

Client-Side Routines

sGetFormattedDate (client-side)

Server-Side Routines

sFormatString (server-side)


All rights reserved.