Chapter 9: Making Decisions with Control Statements . . . . . . . . . .111 Using Boolean Expressions ........................................................................111 Using variables in Boolean expressions .........................................113 Using Boolean operators ..................................................................114 Exploring IF THEN Statements ..................................................................119 IF THEN ELSE statements .................................................................120 Working with SELECT CASE Statements ..................................................121 Checking a range of values ...............................................................124 Checking a relational operator ........................................................125
Chapter 10: Repeating Yourself with Loops . . . . . . . . . . . . . . . . . . . . .129 Using the WHILE-WEND Loop ....................................................................130 Exiting a WHILE-WEND loop prematurely ......................................131 Endless loops #1: Failing to modify the Boolean expression
inside the loop ...............................................................................132 Endless loops #2: Failing to initialize a Boolean expression
outside the loop .............................................................................133 Looping a Fixed Number of Times ............................................................134 Counting with different numbers ....................................................135 Counting in increments ....................................................................135 Exiting a FOR-NEXT loop prematurely ............................................137
xi Table of Contents
Beginning Programming For Dummies, 3rd Edition xii
Part III: Advanced Programming with Liberty BASIC ..................................................139
Chapter 11: Writing Large Programs by Using Subprograms . . . . . .141 Breaking the Bad Programming Habits of the Past .................................141 Introducing Structured Programming ......................................................144 Sequential instructions .....................................................................144 Branching instructions .....................................................................144 Looping instructions .........................................................................145 Putting structured programming into practice .............................146 Writing Modular Programs .........................................................................147 Using Subroutines .......................................................................................150 Defining a subroutine ........................................................................151 Passing data to a subroutine ............................................................151 Calling a subroutine ..........................................................................153 Exiting prematurely from a subroutine ..........................................154 Using Functions ...........................................................................................155 Defining a function ............................................................................155 Passing data to a function ................................................................156 Calling a function ...............................................................................156 Exiting prematurely from a function ...............................................158 Passing Data by Value or by Reference ....................................................158
Chapter 12: Drawing Pictures and Making Noise . . . . . . . . . . . . . . .161 Creating a Graphics Control ......................................................................161 Using Turtle Graphics .................................................................................162 Defining line thickness ......................................................................166 Defining line colors ...........................................................................167 Drawing Circles ...........................................................................................168 Drawing Boxes .............................................................................................170 Displaying text .............................................................................................171 Making Sounds ............................................................................................172 Making a beeping noise ....................................................................173 Playing WAV files ................................................................................173
Untitled Part 1
Beginne am Anfang
