07.05.2015 Views

Download the PDF documentation - True BASIC

Download the PDF documentation - True BASIC

Download the PDF documentation - True BASIC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

29<br />

<strong>True</strong> <strong>BASIC</strong> Language System<br />

REPSTR$ Function<br />

Library:<br />

Syntax:<br />

Usage:<br />

Summary:<br />

Details:<br />

Example:<br />

STRLIB.TRC<br />

REPSTR$ (strex, strex, strex)<br />

LET a$ = REPSTR$ (text$, old$, new$)<br />

Returns <strong>the</strong> value of text$ with all occurrences of <strong>the</strong> value of old$ replaced by <strong>the</strong> value<br />

of new$.<br />

The REPSTR$ function replaces occurrences of one substring with ano<strong>the</strong>r. It returns <strong>the</strong><br />

value of text$ after having replaced any occurrences of <strong>the</strong> value of old$ with <strong>the</strong> value of<br />

new$.<br />

If <strong>the</strong> value of old$ does not appear within <strong>the</strong> value of text$, <strong>the</strong> REPSTR$ function<br />

returns <strong>the</strong> value of text$ untouched.<br />

The following program:<br />

LIBRARY “STRLIB.TRC”<br />

DECLARE DEF RepStr$<br />

OPEN #1: NAME “InFile”, ORG BYTE<br />

OPEN #2: NAME “OutFile”, CREATE NEW, ORG BYTE<br />

LET cr$ = Chr$(13)<br />

LET crlf$ = cr$ & Chr$(10)<br />

DO WHILE MORE #1<br />

READ #1, BYTES 10000: block$<br />

WRITE #2: RepStr$(line$, cr$, crlf$)<br />

LOOP<br />

Exceptions:<br />

See also:<br />

END<br />

copies <strong>the</strong> contents of <strong>the</strong> file named INFILE to <strong>the</strong> newly created file named OUTFILE,<br />

changing all occurrences of a carriage return to a carriage return followed by a line feed.<br />

None<br />

REPMIX$, REPCHAR$, DELSTR$, PLUGSTR$<br />

REVERSE$ Function<br />

Library:<br />

Syntax:<br />

Usage:<br />

Summary:<br />

Details:<br />

Example:<br />

STRLIB.TRC<br />

REVERSE$ (strex)<br />

LET a$ = REVERSE$ (string$)<br />

Returns <strong>the</strong> value of its argument string$ with all of its characters in reverse order.<br />

The REVERSE$ function accepts a string argument, reverses <strong>the</strong> order of <strong>the</strong> characters<br />

which it contains, and returns <strong>the</strong> result.<br />

If <strong>the</strong> value of its argument is <strong>the</strong> null string, <strong>the</strong> REVERSE$ function will return <strong>the</strong> null<br />

string.<br />

The following program:<br />

LIBRARY "StrLib.trc"<br />

DECLARE DEF Reverse$<br />

DIM text$(3)<br />

MAT READ text$<br />

DATA madam, im, adam<br />

FOR i = 1 to 3<br />

IF text$(i) = Reverse$(text$(i)) <strong>the</strong>n<br />

PRINT text$(i); " is a palindrome"<br />

ELSE

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

Saved successfully!

Ooh no, something went wrong!