Views
1 year ago

Learn to Program with Small Basic

Learn to Program with Small

Learn to Program with Small Basic An Introduction to Programming with Games, Art, Science, and Math majed marji and ed price

  • Page 2: Learn to Program with Small Basic
  • Page 5 and 6: Learn to Program with Small Basic.
  • Page 8 and 9: Contents in Detail Foreword by Vija
  • Page 10 and 11: Stick with Your Style .............
  • Page 12 and 13: Create a Game: Guess My Coordinates
  • Page 14 and 15: Infinite Loops ....................
  • Page 16: 18 Advanced Text Magic 263 The Text
  • Page 19 and 20: These two lines of code just printe
  • Page 21 and 22: And above all, my gratitude goes to
  • Page 23 and 24: Who Should Read This Book? You! Thi
  • Page 25 and 26: Review Questions Test your knowledg
  • Page 27 and 28: numbers (like in fantasy football),
  • Page 29 and 30: The Small Basic Library The Small B
  • Page 31 and 32: community. Small Basic even gives y
  • Page 33 and 34: Throughout this book we’ll includ
  • Page 35 and 36: This program uses the DrawText() me
  • Page 38 and 39: 2 Getting Started Now we’ll walk
  • Page 40 and 41: careful not to use too many comment
  • Page 42 and 43: application. But you should get int
  • Page 44 and 45: String Number TextWindow.WriteLine(
  • Page 46 and 47: TextWindow.CursorLeft = 4 TextWindo
  • Page 48 and 49: 15, or multiply 6 times the sum of
  • Page 50 and 51: Logic Errors Sometimes, you might m
  • Page 52 and 53:

    3 Drawing Basics With Small Basic y

  • Page 54 and 55:

    second line to the right, at the (1

  • Page 56 and 57:

    Rectangles and Squares Using the Dr

  • Page 58 and 59:

    (x, y) Height Width Figure 3-8: The

  • Page 60 and 61:

    6 GraphicsWindow.DrawEllipse(20, 20

  • Page 62 and 63:

    By layering text on top of other te

  • Page 64 and 65:

    Programming Challenges If you get s

  • Page 66:

    10. Write a program that draws the

  • Page 69 and 70:

    What’s a Variable? A variable is

  • Page 71 and 72:

    Changing the Value of a Variable Wh

  • Page 73 and 74:

    3. Variable names in Small Basic ar

  • Page 75 and 76:

    Simplifying Expressions Variables c

  • Page 77 and 78:

    Now that you’ve defined your prob

  • Page 79 and 80:

    Note Most other programming languag

  • Page 81 and 82:

    Figure 5-1: Hello, turtle! You migh

  • Page 83 and 84:

    1 ' MoveTo.sb 2 Turtle.Show() 3 Pro

  • Page 85 and 86:

    Turtle.Show() Turtle.Move(150) Turt

  • Page 87 and 88:

    Introducing the For Loop As you sta

  • Page 89 and 90:

    NOTE Programmers usually use one-le

  • Page 91 and 92:

    If the turn angle is 144 instead of

  • Page 93 and 94:

    epeatCount = 4 repeatCount = 6 repe

  • Page 95 and 96:

    Using triangle with repeatCount = 1

  • Page 98 and 99:

    6 Getting User Input To perform use

  • Page 100 and 101:

    Introducing Yourself to Your Comput

  • Page 102 and 103:

    5 TextWindow.Pause() 6 7 TextWindow

  • Page 104 and 105:

    15 25 Average = 17.5 The program pr

  • Page 106:

    Programming Challenges If you get s

  • Page 109 and 110:

    To use any of the Math object metho

  • Page 111 and 112:

    Run the program to see how much mon

  • Page 113 and 114:

    Rounding to the Nearest Hundredth L

  • Page 115 and 116:

    TRY IT OUT 7-3 Your favorite potato

  • Page 117 and 118:

    Random Numbers Random numbers are u

  • Page 119 and 120:

    After the prompt, the program reads

  • Page 122 and 123:

    8 Making Decisions with If Statemen

  • Page 124 and 125:

    Small Basic automatically indents I

  • Page 126 and 127:

    But what if the applicant also need

  • Page 128 and 129:

    Did it work this time? Yep! The rea

  • Page 130 and 131:

    If (condition1) Then Statement(s) I

  • Page 132 and 133:

    The Goto Statement The Goto stateme

  • Page 134:

    2. Captain James P. Cork is pilotin

  • Page 137 and 138:

    statements. We’ll also introduce

  • Page 139 and 140:

    12 Else 13 grade = "F" 14 EndIf 15

  • Page 141 and 142:

    thingie And thingie is true only if

  • Page 143 and 144:

    1 ' AndDemo.sb 2 TextWindow.Write("

  • Page 145 and 146:

    This code finds A = 1 Or B = 1 firs

  • Page 147 and 148:

    Line 4 calls the Move() method to m

  • Page 149 and 150:

    11 path = Program.Directory ' Progr

  • Page 151 and 152:

    window. To do this, you add 12 to X

  • Page 153 and 154:

    128 Chapter 9 3. Obi-Wan Kenobi nee

  • Page 155 and 156:

    Subroutines are basic building bloc

  • Page 157 and 158:

    on line 5 means “run the subrouti

  • Page 159 and 160:

    1 ' LandArea.sb 2 ' Calculates the

  • Page 161 and 162:

    To try out this concept, you’ll p

  • Page 163 and 164:

    TRY IT OUT 10-3 Play the Pepper Dar

  • Page 165 and 166:

    Next, you’ll work on the subrouti

  • Page 167 and 168:

    Step 4: Let the Player Know What’

  • Page 169 and 170:

    6 7 If (dist = 0) Then ' Checks whe

  • Page 171 and 172:

    Step 9: Swing the Sword with StabDr

  • Page 173 and 174:

    have your main program call DrawHea

  • Page 175 and 176:

    y the operating system (see Figure

  • Page 177 and 178:

    GraphicsWindow.MouseDown = OnMouseD

  • Page 179 and 180:

    5. The KeyDown event is raised cont

  • Page 181 and 182:

    1 ' Scribble.sb 2 GraphicsWindow.Mo

  • Page 183 and 184:

    60 120 180 240 300 360 420 480 60 1

  • Page 185 and 186:

    12 Shapes.Move(player, XP * 60, YP

  • Page 187 and 188:

    Step 4: Update the User’s Score T

  • Page 190 and 191:

    12 Building Graphical User Interfac

  • Page 192 and 193:

    Hello there, Alpaca Bag! Start Smal

  • Page 194 and 195:

    firstName variable (line 16). This

  • Page 196 and 197:

    TRY IT OUT 12-2 You can change the

  • Page 198 and 199:

    40 80 120 160 200 240 280 320 360 4

  • Page 200 and 201:

    Step 4: Respond to Changes Add the

  • Page 202 and 203:

    Note You’ll need Small Basic vers

  • Page 204:

    2. In this exercise, you’ll creat

  • Page 207 and 208:

    The For Loop Let’s say you want t

  • Page 209 and 210:

    1 ' MovingWord.sb 2 For N = 0 To 40

  • Page 211 and 212:

    9 TextWindow.CursorLeft = 14 ' Move

  • Page 213 and 214:

    Here’s the output: 10 8 6 4 2 0 M

  • Page 215 and 216:

    3 j = 1 c 1 1 2 3 j = 4 c 2 2 c j =

  • Page 217 and 218:

    15 EndFor 16 EndFor 17 EndFor Listi

  • Page 220 and 221:

    14 Creating Conditional While Loops

  • Page 222 and 223:

    This piece of code simply says, “

  • Page 224 and 225:

    Tip Make sure you initialize any va

  • Page 226 and 227:

    Images P1, P2, and P3 show the play

  • Page 228 and 229:

    TIP If you want to find out the exa

  • Page 230:

    2. Open the file SimpleSlot.sb from

  • Page 233 and 234:

    eferenced using a string index, suc

  • Page 235 and 236:

    This line of code adds five to the

  • Page 237 and 238:

    Constant Initialization The followi

  • Page 239 and 240:

    Here’s the output of this loop: a

  • Page 241 and 242:

    TRY IT OUT 15-4 Write a program tha

  • Page 243 and 244:

    3 ans[2] = "It is decidedly so. By

  • Page 245 and 246:

    20 numMissed = 0 ' Missed apples 21

  • Page 247 and 248:

    7 CheckCatch() ' Checks if the appl

  • Page 249 and 250:

    and bounces to the left or to the r

  • Page 252 and 253:

    16 Storing Data with Associative Ar

  • Page 254 and 255:

    Let’s look at some sample runs of

  • Page 256 and 257:

    TRY IT OUT 16-1 What’s the output

  • Page 258 and 259:

    This code uses the Array object’s

  • Page 260 and 261:

    6 For N = 1 To Array.GetItemCount(n

  • Page 262 and 263:

    Step 2: Set Up the Graphical User I

  • Page 264:

    TRY IT OUT 16-4 Run your poet progr

  • Page 267 and 268:

    The arrays you’ll make in this ch

  • Page 269 and 270:

    Following along with this figure, w

  • Page 271 and 272:

    To move the square, we call the Mov

  • Page 273 and 274:

    Going Interactive Let’s explore h

  • Page 275 and 276:

    Duckberg Industries December Sales

  • Page 277 and 278:

    TRY IT OUT 17-5 Donald wants to rev

  • Page 279 and 280:

    Forest Rain btnN btnE btnS btnW Flo

  • Page 281 and 282:

    8 ShowLocation() ' Gives feedback t

  • Page 283 and 284:

    Step 6: Show the Player’s Locatio

  • Page 285 and 286:

    We mentioned that the old compass h

  • Page 288 and 289:

    18 Advanced Text Magic Although pic

  • Page 290 and 291:

    Earlier in the book, you learned ho

  • Page 292 and 293:

    The GetSubText() Method To extract

  • Page 294 and 295:

    3 lwrCase = Text.ConvertToLowerCase

  • Page 296 and 297:

    a: 97 b: 98 1: 49 2: 50 Fancy Chara

  • Page 298 and 299:

    Armed with the knowledge you’ve g

  • Page 300 and 301:

    sixth digits, and so on. If any two

  • Page 302 and 303:

    TRY IT OUT 18-7 Write a program tha

  • Page 304 and 305:

    Listing 18-9 shows the main part of

  • Page 306 and 307:

    Page1 This is the House that Jack b

  • Page 308 and 309:

    Lines 2-8 set up the GraphicsWindow

  • Page 310:

    Complete the GetInput() subroutine,

  • Page 313 and 314:

    In most programming languages, work

  • Page 315 and 316:

    The filesystem has a tree structure

  • Page 317 and 318:

    5 TextWindow.WriteLine(str) 6 TextW

  • Page 319 and 320:

    output file (line 16). If the file

  • Page 321 and 322:

    When you run this program, it creat

  • Page 323 and 324:

    To keep the code simple, we didn’

  • Page 325 and 326:

    WARNING When you call DeleteDirecto

  • Page 327 and 328:

    We automatically load the contents

  • Page 329 and 330:

    16 TextWindow.WriteLine("The game w

  • Page 331 and 332:

    2. Write a science quiz that tests

  • Page 333 and 334:

    Review Questions Test your knowledg

  • Page 335 and 336:

    C CaptainCork_ Incomplete.sb, 109 c

  • Page 337 and 338:

    Format Program, 99 FrenchDay.sb, 23

  • Page 339 and 340:

    MovingWord.sb, 184 .mp3 files, 289

  • Page 341 and 342:

    Small Basic, continued integrated d

  • Page 343 and 344:

    Updates Visit http://nostarch.com/s

Quick Start to Small Basic - CSTA
Chapter 4: Programming with MATLAB - FET
Smarty PHP Template Programming and Applications by Lucian ...
Part II: Writing Your Own Java Programs - Parent Directory
Bronze Edition Guide - True BASIC
Programming in C
A SPECIAL LOOK AT SMALL BUSINESS: - Bombjack.org
Programming with CellSs - Prace Training Portal
Quick start guide to programming C-Bus2 Learn Units - Clipsal
dakin5-programming-aids-33-manual
GIS and Programming with Visual Basic
Professional PHP Programming
(ebook) - O'Reilly - Advanced Perl Programming.pdf
Chapter 1 Sample Code Real-Time Programming Two Types of ...
Introduction to functional programming
Download the documentation - True BASIC
IntroProgXNAGameStudio_eBook