19.04.2017 Views

Learn to Program with Small Basic

Create successful ePaper yourself

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

18<br />

Advanced Text Magic<br />

Although pictures of blue skies and green<br />

fields are prettier <strong>to</strong> look at than a screen<br />

full of words, many useful programs, such<br />

as Facebook, Twitter, and Words <strong>with</strong> Friends,<br />

work <strong>with</strong> text. That’s why <strong>Small</strong> <strong>Basic</strong> provides the Text<br />

object for working <strong>with</strong> text. In this chapter, you’ll learn<br />

how <strong>to</strong> use the Text object <strong>to</strong> find the length of a string, extract a small portion<br />

of a string, and perform many other advanced string-processing tasks.<br />

You’ll also write your own string-processing subroutines and apply what you<br />

learn <strong>to</strong> create some interesting applications, like a pig latin transla<strong>to</strong>r and a<br />

word scramble game!<br />

The Text Object<br />

You’ve been working <strong>with</strong> strings throughout this book. To recap, a string is<br />

a sequence of characters that is enclosed between double quotes, such as<br />

"stringY strinGy striNg strIng stRing". These characters can include letters

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

Saved successfully!

Ooh no, something went wrong!