TabExpand()

TabExpand()

Replace tabulator control characters with fill characters

Syntax

       TabExpand(<cString>, [<nTabWidth>],
                [<cFillChar|nFillChar>],
                [<cNewLineCharacters>],
                [<cTabChar|nTabChar>],
                [<lIgnore141>]) -> cExpandedString

Arguments

<cString> String to alter

<nTabWidth> Tab width

<cFillChar|nFillChar> Fill Character

<cNewLineCharacters> string indicating new line, default is the string returned by hb_eol()

<cTabChar|nTabChar> character indicating a tab stop, default is chr(9)

<lIgnore141> .T., if the soft-CR used by MEMOEDIT() should be ignored as a newline indicator, default is .F. (functions uses chr(141))

Returns

The modified <cString> is returned.

Description

The TabExpand() function replaces all tab characters (CHR(9)) in <cString> with the corresponding number of spaces or <cCharacter| nCharacter>. The <nTabWidth> parameter can be used to set varying tab widths.

Notes

. In the absence of the <nTabWidth> parameter, TabExpand() has a default tab width of 8. . The carriage return and line feed, where the high bit is set, are taken into consideration. . SETTABS() does not affect this function.

Examples

       .  TabExpand() only fills to the next tab position:
          ? TabExpand("-" +CHR(9) +"!")                  // "-       !"
          ? TabExpand("----" +CHR(9) +"!")               // "----    !"
       .  You can fill with any character you like:
          ? TabExpand("-" +CHR(9) +"!", "+")             // "-+++++++!"
       .  The tab width can be selected:
          ? TabExpand("-" +CHR(9) +"!", 4)               // "-   !"
          ? TabExpand("----" +CHR(9) +"!", 8)            // "----    !"
          ? TabExpand("----" +CHR(9) +"!", 8, "+")       // "----++++!"

Tests

       TabExpand("-"+chr(9)+"!")             == "-       !"
       TabExpand("----"+chr(9) +"!")         == "----    !"
       TabExpand("-"+chr(9)+"!",, "+")       == "-+++++++!"
       TabExpand("-"+chr(9)+ "!", 4)         == "-   !"
       TabExpand("----"+chr(9)+ "!", 8)      == "----    !"
       TabExpand("----"+chr(9)+ "!", 8, "+") == "----++++!"
       TabExpand("-"+chr(9)+"!"+hb_eol()+"----"+chr(9)+ "!",, "+") 
                == "-+++++++!"+hb_eol()+"----++++!"

Compliance

TabExpand() is compatible with CT3’s TabExpand(), but there are three new parameters for a better fine control of the function’s behaviour.

Platforms

All

Files

Source is tab.c, library is libct.

Seealso

TabPack()

2 responses to “TabExpand()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – T | 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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.