TabPack()
Pack fill characters to appropriate tab characters
Syntax
TabPack( <cString>, [<nTabWidth>], [<cFillChar|nFillChar>], [<cNewLineCharacters>], [<cTabChar|nTabChar>], [<lIgnore141>] ) -> cPackedString
Arguments
<cString> String to alter <nTabWidth>
<cFillChar|nFillChar> Width of tab or character to use to fill <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
TABPACK() returns the modified character string.
Description
This function does not simply exchange a simple sequence of the same characters for a tab; instead, it takes into account the true tab positions. If a space (or the <cCharacter|nCharacter>) is found at a tab position, and immediately preceding it there is at least one identical character, the function replaces this sequence (maximum <nTabWidth>) with a CHR(9). With tab characters, text can be packed by individual tab widths. As with every good text editor, there is no replacement with a tab within single or double leading characters.
Notes
. For the beginning of a line, the function takes into account the “normal” carriage return (CHR(13)/CHR(10)) as well as the high bit return (CHR(141)) used by MEMOEDIT(). Previously existing tab characters are also taken into account. . If another tab already exists, this tab can be removed with TABEXPAND(). The new tab can then be inserted using TABPACK().
Example
We have avoided replacing spaces with tabs in the following examples to keep the example legible. Tab width is 8 (default). "*" is exchanged for tab characters. ? TABPACK("AAAAAAA*", "*") // "AAAAAAA*" ? TABPACK("AAAAA***", "*") // "AAAAA" + CHR(9) ? TABPACK("AAAAA*****", "*") // "AAAAA" + CHR(9) + "**" crlf := CHR(13) + CHR(10) cText := "ABCD+" + crlf + "++---+++++" ? TABPACK(cText, 4, "+") // "ABCD+" + crlf + // "++---" + CHR(9) + "++"
Compliance
TabPack() is compatible with CT3’s TabPack(), but extended by Harbour; 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
TabExpand()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – T | Viva Clipper !