09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>XENIX</strong> Programming m4: Macro Processor<br />

Manipu lati ng Strings<br />

The built-in len returns the length of the string that makes up its argument. Thus<br />

is 6, and<br />

is 5.<br />

len(abcdef)<br />

len( (a,b) )<br />

The built-in substr can be used to produce substrings of strings. For example<br />

substr(s, i, n)<br />

returns the substring of s that starts at position i (origin zero) and is n characters long.<br />

If n is omitted, the rest of the string is returned, so<br />

is<br />

substr('now is the time', 1)<br />

ow is the time<br />

The command<br />

i ndex(s 1 ,s2)<br />

returns the index (position) in sl where the string s2 occurs, or -1 if it doesn't occur. As<br />

with substr, the origin for strings is 0.<br />

The built-in translit performs character transliteration.<br />

translit(s, f, t)<br />

modifies s by replacing any character of s found in f by the corresponding character of<br />

t. That is<br />

translit(s, aeiou, 12345)<br />

replaces the vowels in s with the corresponding digits. If t is shorter than f, characters<br />

that don't have an entry in t are deleted; as a limiting case, if t is not present at all,<br />

characters from f are deleted from s. So<br />

transl it(s, aeiou)<br />

deletes vowels from s.<br />

11-9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!