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.

Figure 16-1 shows the user interface for the application.<br />

Figure 16-1: The user interface for Poet.sb<br />

Every time you click the New but<strong>to</strong>n, the poet recites a new poem. Each<br />

poem includes three lines that follow these patterns:<br />

• Line 1: article, adjective, noun<br />

• Line 2: article, noun, verb, preposition, article, adjective, noun<br />

• Line 3: adjective, adjective, noun<br />

The following sections guide you through the creation of this program.<br />

Step 1: Open the Startup File<br />

Open the file Poet_Incomplete.sb from this chapter’s folder. The file contains<br />

one subroutine named CreateLists(), which creates the five lists you’ll need<br />

in this program. This subroutine was added <strong>to</strong> save you from having <strong>to</strong> type<br />

a whole bunch of words. This is what it looks like:<br />

Sub CreateLists<br />

article = "1=a;2=the;...;5=every;"<br />

adjective = "1=beautiful;2=blue;...;72=young;"<br />

noun = "1=baby;2=bird;...;100=winter;"<br />

verb = "1=admires;2=amuses;...;92=whispers;"<br />

prepos = "1=about;2=above;...;37=<strong>with</strong>out;"<br />

EndSub<br />

The ellipses (...) take the place of the missing array elements, but you<br />

can see all these elements when you open the file. Note that the article<br />

array also includes other determiners, such as one, each, and every.<br />

236 Chapter 16

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

Saved successfully!

Ooh no, something went wrong!