07.05.2015 Views

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

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.

212 BRONZE <strong>Edition</strong> <strong>Guide</strong><br />

sequence, options$. If you use typed commands, anything you type following the do<br />

command itself and a comma will be similarly assigned. (For the typed command, you’ll<br />

automatically use the TBDo directory; see the discussion of aliases in Chapter 15.)<br />

Here is a simple example: Suppose you want a do program that will change all upper<br />

case letters into lowercase, or all lower case letters into uppercase. Write the following<br />

subroutine:<br />

EXTERNAL<br />

SUB xxxxx (current$(), options$)<br />

LET options$ = ltrim$(lcase$(options$))[1:1]<br />

FOR i = 1 to ubound(current$())<br />

IF options$ = “u” then<br />

LET current$(i) = ucase$(current$(i))<br />

ELSE IF options$ = “l” then<br />

LET current$(i) = lcase$(current$(i))<br />

ELSE<br />

PRINT “Use either ‘upper’ or ‘lower’”<br />

EXIT SUB<br />

END IF<br />

NEXT i<br />

END SUB<br />

Now save it with the name “ChangeCase” in the directory TBDo.<br />

To use your new DO program to change all uppercase letters to lowercase in your current<br />

program, type the command<br />

do changecase, lower<br />

Conversely, if you want to change to all uppercase, type the command<br />

do changecase, upper<br />

That’s all there is to it.<br />

If you put your very own DO program in the directory (folder) TBDo, its name will<br />

appear in the Run menu the next time you start <strong>True</strong> <strong>BASIC</strong>. If you put it into a different<br />

directory, you can access it by selecting “Do ...” from the Run menu, using the Finder<br />

to locate it, and then clicking on “Open”. In any case, you will be asked if there are any<br />

command-line parameters; whatever you enter will be supplied as the value of options$<br />

in the call to the DO program.

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

Saved successfully!

Ooh no, something went wrong!