StrFormat()

StrFormat()

Format a string

Syntax

      StrFormat(<cMask>[, <cPar1>[, <cParn>[, ...]]) --> cString

Arguments

<cMask> Holds the mask for the resulting string

<cParn> Holds the strings to be inserted in the mask maximum 9 of them can be specified.

Returns

<cString> Return the mask with all the parameters inserted.

Description

String replacment, can be useful when writing international apps. You can separate the constant strings from the variable ones. Each %1 – %9 marks will be replaced with the appropriate parameter from the parameter list.

Marks can be in any order, and can be duplicated.

You can print “%” character with “%%”.

Examples

      StrFormat( "Please insert disk %1 to drive %2", hb_ntos( 2 ), "A:" )
      StrFormat( "This is %1 from %2", "Victor", "Hungary" )
      StrFormat( "%2 %1 %2", "Param1", "Param2" )

Tests

      ? StrFormat( "Please insert disk %1 to drive %2", hb_ntos( 2 ), "A:" )
      ? StrFormat( "This is %1 from %2", "Victor", "Hungary" )
      ? StrFormat( "%2 %1 %2", "Param1", "Param2" )
      ? StrFormat( "Hello" )
      ? StrFormat( "%1 - %2", "one" )
      ? StrFormat( "%1 - %2", "one", "two" )
      ? StrFormat( "%2 - %1", "one", "two" )
      ? StrFormat( "%2 - %", "one", "two" )
      ? StrFormat( "%% - %", "one", "two" )
      ? StrFormat( "%9 - %", "one", "two" )

Compliance

All platforms

Files

Library is libmisc

Seealso

Transform(), Stuff(), StrTran()

Advertisements

2 responses to “StrFormat()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – S | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s