15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

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

590<br />

The Structure of a BASIC Program<br />

Basic, which makes it possible to translate or port a Visual Basic program<br />

into REALbasic so you can create a Linux or Macintosh version of a Visual<br />

Basic program.<br />

Both Visual Basic and REALbasic are the most prominent BASIC dialects that<br />

offer structured <strong>programming</strong> and object-oriented <strong>programming</strong>. Two simpler<br />

BASIC dialects that omit object-oriented features are Liberty BASIC (www.<br />

libertybasic.com) <strong>for</strong> Windows and Chipmunk BASIC (www.nicholson.<br />

com/rhn/basic) <strong>for</strong> the Macintosh. You can also visit the Run BASIC site<br />

(www.runbasic.com) to practice writing BASIC programs through any<br />

browser.<br />

The Structure of a BASIC Program<br />

In the original BASIC language, a program consisted of one or more commands<br />

listed one after another, such as<br />

PRINT “This is a simple BASIC program”<br />

END<br />

For creating simple programs, BASIC lets you get started right away by<br />

focusing only on the commands you need. To create more complicated programs,<br />

you can create a single main program and one or more subprograms.<br />

The main program always runs first and determines when to run commands<br />

stored in different subprograms.<br />

In both Visual Basic (VB) and REALbasic (RB), there’s no main program.<br />

Instead, a typical VB/RB program consists of a single project file that lists<br />

the names of all files that make up that program. The three main types of<br />

files used in a project are<br />

✦ Window files<br />

✦ Module files<br />

✦ Class files<br />

Using windows files<br />

A window file contains a single window and various controls that appear on<br />

that window, such as buttons, pull-down menus, or sliders. Besides containing<br />

the user interface, a window file also contains subprograms that tell each<br />

control, on that user interface, how to respond to an event.<br />

Such subprograms, or event subprograms, tell the computer how to respond<br />

when the user does something, such as click the mouse or move the mouse<br />

over a control. Unlike a traditional BASIC program where the main program

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

Saved successfully!

Ooh no, something went wrong!