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()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – T | Viva Clipper !