Adjusts a sequence within a string to a specified position
AtAdjust( <cStringToMatch>, <cString>, <nAdjustPosition>, [<nCounter>], [<nIgnore>], [<nFillChar|cFillChar>] ) -> cString
<cStringToMatch> is the sequence to be adjusted within <cString>
<cString> is the string that contains <cStringToMatch>
<nAdjustPosition> specifies the position to that <cStringToMatch> will be adjusted
[<nCounter>] specifies which occurence of <cStringToMatch> in <cString> is to be adjusted. Default: last occurence
[<nIgnore>] specifies how many characters should be omitted in the scan
[<nFillChar|cFillChar>] specifies the character that is used for the adjustment
<cString> the changed string
The function first looks for the <cSearchFor> parameter within the character string. From this point, the rest of the <cString> is moved (adjusted) by either inserting or removing blanks until the <nTargetPosition> is reached. In lieu of blanks, <nCharacter> | <cCharacter> can be used as a fill character.
Additionally you can specify that the nth occurrence of be used and whether or not a specific number of characters at the beginning of the search string is eliminated.
Using CSETATMUPA() can influence how the search is performed.
Using SETATLIKE() permits the use of wild cards within the search sequence.
. Align comments at column 60. The search is for the first occurrence of "//". Since there is usually at least one space before each "//", search for " //": ? AtAdjust(" //", Line, 60, 1) . Move the extensions for the following list of file names to position 10 and eliminate the ".": WINDOW.DBF PLZ.DBF BACK.DBF HELP.DBF LOG.DBF CHARREM(".", AtAdjust(".", File, 10)) WINDOW DBF PLZ DBF BACK DBF HELP DBF LOG DBF
Use AtAdjust() with CSETATMUPA(). There is always a problem determining whether “AA” occurs twice or three times in “AAA”. Depending on CSETATMUPA(), the function searches behind the last character, or starts from the last character of a located sequence:
CSETATMUPA(.F.) ? AtAdjust("AA", "123AAABBB", 7, 2) // Sequence not found CSETATMUPA(.T.) ? AtAdjust("AA", "123AAABBB", 7, 2) // "123A AABBB"
AtAdjust() works like CT3’s AtAdjust()
Source is AtAdjust.c, library is ct3.