JCL Help:StrExpandTabs@string@TJclTabSet

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Expands tabs to spaces in the provided string.


Pascal

 function StrExpandTabs(S: string; TabSet: TJclTabSet): string;


Parameters

Parameters Description
S: string The string to expand tabs in.
TabSet: TJclTabSet The tab set to use.


Return Value

If S contains tabs, they will have been converted to 1 or more space characters, depending on the column the tab character is in. Otherwise, the string is unmodified.


Description

StrExpandTabs expands tab characters in the provided string into sequences of spaces while preserving the formatting. StrExpandTabs will use the provided tab set.
Multi-line strings, ie. strings containing one or more newline sequences (eg. CrLf, but also single Cr of Lf characters are treated as newlines), are handled properly.
The reverse operation (collapse sequences of spaces into tab characters) can be achieved by the StrOptimizeTabs method.


Examples

  // initiate a tab set with (zero-based) stops at 15, 20 and 30, and a tab width of 2 for
// tabs beyond the column 30
tabs := TJclTabSet.Create([15, 20, 30], True, 2);
try
x := StrExpandTabs('MyLabel:'#9'LD'#9'A,(HL)'#9'; Initialize A register', tabs);
finally
tabs.Free;
end;
The above snippet will result in x containing the string (· represents a space character): MyLabel:·······LD···A,(HL)····;·Initialize·A·register. In this case the first tab character (ASCII code 9) was transformed into seven spaces, the second tab character into three spaces and the third tab character into four spaces.


See Also

TJclTabSet StrExpandTabs@string StrExpandTabs@string@Integer


About

Unit

JclStrings


Donator

Marcel Bestebroer


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page