REALbasic University Resources:

RBU: Glossary Defines common REALbasic programming terms
  Archives Previously published columns
Translations: Dutch Courtesy of Floris van Sandwijk
  Japanese Courtesy of Kazuo Ishizuka
  Chinese Courtesy of Dong Li
  RBU Translation Guide Information on Translating RBU into other languages
Books: Matt's Book (2nd Edition!) Ideal for experienced programmers
  Erick's Book Best for beginning programmers
Websites: Mother Ship The publisher of REALbasic
  RB Webring Links to hundreds of REALbasic websites
  RESExcellence Another REALbasic programming column
  REALbasic Developer Magazine The premiere source for REALbasic instruction.

REALbasic University is Sponsored by

Make your Mac do what YOU want it to. Create games, utilities, cool Mac OS X tricks. Download REALbasic now and create your own software.


The REALbasic University Glossary of REALbasic Terms

The REALbasic Glossary
The following is a continually updated list of terms related to REALbasic. As new terms are defined as part of the REALbasic University column, they will be added here. If you don't see a term you think should be here, let me know and I'll consider adding it.


REALbasic Terms

AlgorithmDelimiterObject
APIDisclosure TriangleObject-Oriented Programming
ArrayDoubleOOP
ASCIIEditfieldParameter
AutocompleteEncapsulationParse
BASICError-checkingProperty
BinaryEventPushbutton
BitFile PathREALbasic
BooleanFlagRecursion
Boolean LogicFunctionResource fork
CanvasHandlerRoutine
ClassHexadecimalScope
CodeIDESprite
Collision DetectionInheritanceString
CompilerInstanceSubclass
ConstantIntegerSubroutine
ControlInterpreterSyntax
Control ArrayListboxSyntax Error
Data forkLocalizeThread
Data structureMethodTimer
Data typeModalVariable
DebugModuleVisual Basic


Algorithm

An algorithm is the basic steps taken to solve a problem. An algorithm is not code: it is the process itself, the concept.

For instance, the famous Bubble Sort algorithm is a method for sorting a list. It's very slow but simple: you simply step through the list comparing each line with the previous one, and if they are out of order, swap them. You keep doing that until going through the whole list has no swaps (it's entirely in order). The actual code to implement a Bubble Sort would vary from language to language; the algorithm is the same for all languages.

Here's the algorithm for Bubble Sort:


- Start with the first item
- Compare it to every other item in the list
- If it's bigger, than swap it with the other item
- Repeat the process with the second item in the list
- Repeat with the third item, etc. etc.
- Stop when the entire list as been gone through.

Here's the code for Bubble Sort written in REALbasic:

  
dim i, y, max, thePass as integer
dim noExchanges as boolean
dim theTemp as string

//
// This sorts the string array "theItems"
//

max = uBound(theItems)

if max > 0 then
thePass = 1
do
noExchanges = true
for i = 1 to max - thePass
y = i + 1

if theItems(i) > theItems(y) then
// Swap items
theTemp = theItems(i)

theItems(i) = theItems(y)

theItems(y) = theTemp

noExchanges = false
end if
next // i
thePass = thePass + 1
loop until noExchanges
end if // max > 0

// Rebuild listbox
for i = 1 to uBound(theItems)
termList.addRow theItems(i).term
next

In summary, the algorimth describes the process: code implements that process in a particular language.


API

Application Programmer Interface. Apple includes tons of software routines as part of the Mac OS that developers "call" (use) to generate the familiar Mac OS interface without having to write them from scratch. An API is the list of these routines and the parameters they expect. Essentially an API is simply an explanation of how to use another programmer's routines. When you download a REALbasic class written by another person, they will often include an API explanation of how to use the various methods of their class.


Array

An array is like a data table. It's a variable that holds more than one item. Since an array only has one name, you refer to individual elements of an array by number. In REALbasic, this is done by putting the array name followed by the number in parenthesis like this: theArray(10). Arrays are a simple linear data structure, excellent for lists of information. An array can be of any data type -- you can have an array of numbers or an array of strings. Before you can use an array, you must define it: set aside memory for the contents. In REALbasic you do this with the DIM or REDIM commands. If you attempt to access an element in an array that doesn't exist, your program will crash. For instance, if you have defined theArray as having ten elements and you attempt to access theArray(11) your program will crash.


ASCII

This is an acronym for American Standard Code for Information Interchange. It is a set of standard English characters and punctuation symbols each assigned a unique number from 0 to 127. Computers store all text as numbers. Because almost all computers use the ASCII standard, text passed from one computer to another stays the same. If different computers used different standards, the letter A on one might be a letter Q on another, and we'd have chaos. There are actually 256 character codes representing more than just the basic alphabet, but only those 127 and less are part of the standard. For those extra characters, each computer platform has its own standard. That's why special characters such as accented letters and symbols don't transfer correctly from a Mac to a PC (or vice versa).


Autocomplete

This is a feature of certain software to guess at what the user is attempting to do and finish it for the user. The best example is the way REALbasic will finish typing variable names and methods after the user types the first few letters. It is designed to save the user time, but sometimes it can be distracting, especially to new users.


BASIC

Stands for Beginner's All-purpose Symbolic Instruction Set. BASIC was a programming language created in the 60's to be simple and easy-to-learn. Original versions of BASIC were limited and slow, and were interpreted, not compiled. Today there are many versions of BASIC which are nearly as powerful as C++ but far easier to use (such as REALbasic).


Binary

A base-2 counting system, which means it only uses two base digits (0 and 1). Decimal is the normal human counting system, which has ten base digits (0 through 9). Hexadecimal is a base-16 system (0 through H).


Bit

Short for BInary digiT. Since a binary number only contains 0's and 1's, a single digit would be a bit. Eight bits together is a byte.


Boolean

A boolean is a data type which is either true or false (on or off). One will often use a boolean as flag -- setting, for instance, whether a condition is in state A or B. In REALbasic you can set a boolean variable in two ways. One, you can specify the variable's value with the keyword true or false, or two, you can evaluate a boolean expression: an expression in which the result will be either true or false. An example of the latter:
gameOver = (shipFuel < 1) and (numShips < 1)
In the above, the boolean variable gameOver will only be set to true if both shipFuel and numShips are less than one, otherwise it will be false. This is known as Boolean Logic and is remarkably powerful.


Boolean Logic

Boolean logic is at the heart of computers: all expressions evaluate as either true or false. REALbasic supports the common AND, OR, NOT boolean operators allow you to build sophisticated logical expressions. For instance, you could program an Editfield to only allow numbers to be typed it in by restricting the kinds of keys you allow to pass through the keydown event:
if (key < "0" or key > "9") and key <> "." then
return true
end if
The above code throws out any typed key which is not a number, unless the key is a period -- we've got to allow the user to put in a decimal point.


Canvas

This is an object unique to REALbasic. It represents a rectangular drawing area. It is displayed as an empty gray box within the IDE as the drawing commands are programming code you put inside it. As a canvas receives many events (such as mouseDown), you can use a canvas to create your own custom controls, or simply display a picture.


Class

A class is a category of object. It acts as the template or blueprint for instances of the object. For example, I could create a class called "Person" and include properties within that class for data such as name, sex, height, weight, shoe size, e-mail address, birthday, etc. Then I can create as many instances of that class as I need for each person in my database.


Code

Programming instructions in a language the computer can understand. Code can be low-level (not very human compatible), such as assembly or machine language, or high-level (easier for humans), such as C++, Pascal, or REALbasic. The complexity of programs are often measured by the amount of code, such as "How many lines of code did that game take?"


Collision Detection

A key issue with graphics, especially sprites, is the ability to tell when two objects "collide" (touch) each other. For instance, in a game a spaceship controlled by the user might explode if it touches the cave walls. It is up to the program to detect when the ship collides with the wall. Simple in concept, collision detection is difficult to program. Fortunately, REALbasic's built-in sprite system supports automatic collision detection.


Compiler

A compiler is a computer program that translates English-like programming syntax into assembly language. Unlike interpreted languages, a compiler generates an entire program before it can be executed. See Interpreter for more.


Constant

A variable that isn't variable: that is, its information does not change while a program is running. Generally you use constants to make it easier to update your program. For instance, instead of writing 12 for the number of months, you could use a constant to represent it, and then if the number of months in a year ever changes, you only have to change it in one place. A more likely scenario would be to use hard numbers that represent the column number of some info in a listbox. Say you've decided a "quantity" value will be stored in column 4. So throughout your program you refer to the fourth column to get that data. But later you insert a new column in front of the others: suddenly you've got to go through your entire program and change all those hard references to the correct value. If you use a constant, you only have to change it in one place to fix your entire program.


Control

Also called a user control, a control is an object with an interface that the user can modify. For instance, a push button allows the user to press it. A popup menu allows the user to choose from a list of items. A listbox displays a scrolling list of information. An editfield allows a user to enter text.


Control Array

This is simply an array of a control. An array of controls all have the same name and are only distinguishable by their index number (which is unique). All the controls in a control array have the same code, which is the whole point: you use a control array when you need several nearly duplicate controls. For instance, let's say you're writing an HTML editor which has buttons for Bold, Italic, and other forms of emphasis. The methods of tagging the text are identical; the only difference is the tag itself. By creating a control array of buttons, you can reuse most of the code. A simple check for the index of the button clicked will let you specify the correct tag to apply. This is much easier than writing the same code multiple times for completely different buttons.


Data fork

The Mac OS has a unique file system in which files can have two parts to them. These two parts are known as the data fork and the Resource fork. Generally, in a document file, only the data fork is used. Other operating systems don't have a dual-fork file system and therefore can only access the data fork portion of the file.


Data structure

Almost every computer program works with data: either information input by the user or loaded from a file, or the results of calculations performed by the program. All that information must be stored (remembered) by your program. That's the programıs data structure. As the programmer, you must decide the most efficient and effective method of storing this information. This is a decision you must make during the design stage of your program. Most programming languages have multiple data types and different mechanisms for storing information; some methods are efficient for one kind of data, while others are more efficient for another kind. Your choice depends on what you are going to do with your data (Are you sorting or performing calculations on it?), the expandability of your data (Is the user going to add more data or new types of data?), and the amount of data (the data structure for a program manipulating a few hundred elements is very different from the data structure of a program working with millions of records). Think carefully about the data structure of your program. Try to anticipate future expansion, and analyze how efficient your program can perform functions such as sorting.


Data type

Computers aren't like humans: they can't tell one type of data from another. To you and I, a human face is a person, but to a computer, it's nothing more than a bunch of numbers. You and I might see a series of numbers and think, "Ah! A telephone number." But the computer only sees digits and separators (hyphens or periods or spaces). Because of this, programming languages have strict definitions of data. Since you store data in a variable, you must define what kind of data that variable will contain, and you cannot violate that structure (such as attempting to store a picture inside a variable designed for sound). Some typical REALbasic data types are numbers (integer and double), text (string), and picture.


Debug

The tedious process of finding and correcting errors in a computer program. Bugs range from syntax errors, which prevent a program from compiling, to visual glitches to logic errors (where you think you're telling the computer to do one thing, but you're really telling it to do something else and the results are not what you expected).


Delimiter

A divider character used to separate types of data in a database. The delimiter must be unique to the data or else the fields will be read incorrectly. For instance, many databases will export data in "tab-delimited" format, meaning that each record is on a separate line with each field separated by a tab character.


Disclosure Triangle

This is a triangle-shaped user interface item which either shows or hides information depends on the direction it is pointing. The classic example is their use in the Finder in List view, where folders have disclosure triangles next to them. When the triangle is pointing down, it is considered "open" and the contents of the folder is displayed to the right, while if the triangle points to the right, it is closed and the contents of the folder remain hidden. In some programs, a disclosure triangle hides advanced user interface elements. For instance, in the Remote Access control panel, there's a triangle next to the Setup which either shows or hides extra details such as the user's loggin name, password, and ISP telephone number. To simplify the interface, the user can hide the extra items they don't need.


Double

A numerical data type. Doubles are used for decimal numbers (fractions). 3434.5454 is a valid decimal number. So is 1.0 or -343.00003. If your program needs to handle fractions, you must define your variables as type double.


Editfield

REALbasic's text control. If you place an Editfield object on a window, when your program is executed the user will be able to type text within the boundaries of the Editfield. Clipboard facilities (such as copy and paste) are automatically active. Various settings, such as the "multiline" or "styled" properties, affect how the Editfield works. (Multiline lets a user type in more than one line of text, and styled means the Editfield can have more than one font.)


Encapsulation

Encapsulated code is code that is isolated from other code and grouped together with like routines. An OOP object that contains code and knows how to do things on its own is an example of encapsulated code.
The main advantage of encapsulated code is that a program can communicate with the object or group of code without having to know anything about how that code was programmed.


Error-checking

The process of bug-proofing a program so that minor errors won't bring down the entire program. Never assume that a command to the operating system will work: double-check to make sure it worked. For instance, if you tell the OS to create a new file, check to make sure that it worked before attempting to write to the file. It's entirely possible the file is on a locked volume (such as a CD) and the create file routine failed.


Event

An event is something that happens. Usually this means the user has done something (typed, clicked the mouse button, etc.) but it could also mean that a timer has gone off or a piece of hardware is reporting a condition (the modem detects an incoming call, the user has connected a mouse). With Object-Oriented Programming, events are sent as messages from one object to another. Macintoshes are said to be event-driven, meaning that the user controls the computer, since Mac programs simply sit around waiting to respond to events.


File Path

This is a text description of a file's location. It includes the volume name and all the folder names the file is inside of, delimited by a unique character. On the Mac, file paths are delimited by colons; PCs use a slash. For instance, I might have a file named "Bullwinkle 4/1/01" that's on my Rocky hard drive, and saved in a folder named "Letters". The full path (on a Mac) would be: "Rocky:Letters:Bullwinkle 4/1/01". File paths are not the best way to remember where a file is located because they break if the file is moved or renamed.


Flag

This is a term for a type of variable used to alert the programmer to a particular condition. Typically a flag is a on/off boolean variable. For instance, a game might have flag that's set depending on if the player's a guy or a girl and adjust the game accordingly.


Function

A type of subroutine that returns a value. The definition of the function establishes the data type of the value to be returned. Functions are commonly used to convert one data type to another. For instance, send a function a string and it returns a number, etc. Or a function could take the passed information (say a string) and process it in some manner and return it in the new format (such as lower case).


Handler

A handler is a routine that handles a specific situation. For instance, a menu handler would handle a specific menu item being selected by the user. Handlers are similar to methods or procedures in other languages, but not quite the same: handlers are always responses to an event of some kind, whereas procedures or methods can be called for any reason (not necessarily responding to an event).


Hexadecimal

The name for the base-16 numbering system. The decimal system is base-10 (there are ten digits). Computers think in binary (base-2), ones and zeros (two digits). In hexadecimal there are sixteen digits (0-9 plus A-F). A = 10, B = 11, etc. If you're terrible at math, other based number systems are very confusing. There's no reason why humans couldn't use a numbering system other than decimal, but since we've got ten fingers, that's what we standardized on.


IDE

Integrated Development Environment. Basically this is the editor where you write your code. In the past (dark ages), programs were written in an editor and compiled with a separate program. Today most programming environments feature a built-in (integrated) editor like REALbasic's.


Inheritance

One of the key principles of Object-Oriented Programming (OOP) is that when you create an object, you can base it on another object. This secondary object can gain abilities and characteristics from the first. With the secondary object, you can override the inherited characteristics if you like, and you can add new characteristics and abilities. The benefits of using inheritance is faster programming: your object is already partially built at the start, and by editing the ancestor you can modify all your objects with a few lines of code. As a writer, the metaphor I always like to use for inheritance is the style sheet feature of many word processors and publishing software: if you base one style on another, the new style inherits the characteristics of the ancestor -- changing the font of the ancestor changes the font of all the styles based on it.


Instance

An instance is a version of an object in memory. In a sense, the original object acts like a template or blueprint, and the instance is the actual version alive in memory.


Integer

A data type for numbers. Integers can only be whole numbers (meaning no fractions), but they can be positive or negative. 10 and -2384 are both valid integers. 454.34 is not a valid integer. Computers can usually perform math calculations on integers much faster than with decimal numbers.


Interpreter

Computer languages are either interpreted or compiled; both terms have to do with translating the English-like syntax of a programming language into assembly or machine language. An interpreted language is translated "on the fly," that is, as each line is translated, it is executed. While this makes programming easier (one less step for the user), the code generated is less efficient and therefore slower, and the resulting program cannot run without the original interpreter. For example, original versions of BASIC were interpreted, and therefore you could not run a BASIC program without BASIC on your computer. Today languages like REALbasic are compiled, so no interpreter is needed. However, unlike interpreted forms of BASIC, you cannot execute single commands and see the results immediately (i.e. type in "Print 10*20" and see the result).


Listbox

A Listbox is type of control. It contains a list of items, one item per line. A scrollbar on the right side allows the user to scroll the list if it contains lots of lines. Listboxes have many options that can change how they look and function. Some Listboxes have more than one column, and you can even embed a checkbox, a graphic, or make the text of one field editable. You can also have a "hierarchal" Listbox, which looks like the List View of files in the Finder, and let's you have folders and items inside folders.


Localize

The process of translating and releasing a version of a software program in another language. Localization is a complex and difficult task and requires significant planning. Translating all the text used by your application is difficult: remember, all the text means menus, error messages, labels for interface elements, help files, etc. Often the translation is the simplest part. For instance, the label of a button in English may fit fine, but in another language that same label may be too big. When you're designing your interface, plan for localization: it will save you time in the long run.


Method

Traditional programming uses terms like "procedure" or "function" or "subroutine" for what REALbasic calls Methods. A method is a subroutine that may or may not return a value. A method can be associated a particular object, such as a window. This is how you pass messages between objects. For example, you could create a generic error message dialog box and call its "display" method (a method you wrote) which accepts an error message string as a parameter and then displays the dialog box with that error message.


Modal

A program is considered modal when it locks the user into a particular mode. A mode is when the user can only do certain commands or functions within that mode, while other commands are available in a different mode. Modes are often confusing to users, especially beginners who have trouble figuring out what mode they are in. Most old DOS programs on PCs were severely modal while GUI programs are written to be primarily modeless (non-modal), though there are exceptions. For instance, when you choose to open or save a file, a modal save or open dialog is displayed. (You can switch to a different program, but you cannot do anything else in that program until you close the dialog, effectively a mode.) Essentially a modeless program lets the user do whatever they want, at any time, and most users are more comfortable with that approach.


Module

A module is a collection of REALbasic code. A module can contain properties, method, and constants. Whatever a module contains is global to your entire program. The chief advantage of a module is you can group similar functions together, and it is possible to export a module and reuse it in other programs or share it with others.


Object

An abstract (virtual) structure used in Object-Oriented Programming. An object is an arbitrary structure that contains its own code. For example, a push button could be an object that knows how to be pushed, and what to do when pushed.


Object-Oriented Programming

Abreviated as OOP, this is a programming technique that involves creating abstract objects that contain their own code. For instance, a window is an object. The window can know how to open and close itself, even move itself if the user drags its titlebar. Thus all the code for handling the window is encapsulated within the window, which not only makes it easier to find, but is logical.
Objects communicate with each other with messages. For instance, a dialog box could tell a window to save itself and close. If you duplicate an object, you have created an instance of that object. The instance is exactly like the original except it's a copy, meaning it has its own data. If you have a document window and the user opens a second document, each document window is an instance of the original object. Thus handling multiple open documents is simple with OOP -- each window knows its contents, knows how to save itself, and knows how to be manipulated (moved, resized, etc.) by the user. Another important OOP concept is inheritance: you can create variations of an existing object so that it inherits all the capabilities of the previous object, except for a few specific things which you change. For instance, in REALbasic all controls (editField, listBox, etc.) are all based on the rectControl object. Since the rectControl includes basic properties like width, height, name, etc., all controls automatically have those properties. Controls are ideal for OOP since they are so similar yet each is different in appearance or capability. Instead of creating 20 objects from scratch, base them on the same source and you can easily change all the controls at once.
An end-user cannot tell the difference between a program written with OOP and a non-OOP program; the difference is all in how the program is written and how easy it is to rewrite, fix, and enhance. OOP programs (if well-written), are significantly easier to build upon than traditional software, and once you've created an object, you can reuse that object in other programs. For instance, much of the REALbasic code you find on the Internet is in the form of classes (objects) you can pop into your own programs and use without having to understand the actual programming involved.


OOP

See Object-Oriented Programming.


Parameter

A parameter is a piece of information required by a subroutine (or method, in REALbasic parlance). For instance, you could write a routine that converts Fahrenheit temperature to Celsius. The routine would expect a parameter; namely, a number that was the temperature in Fahrenheit. If you failed to include a number, included more than one, or included the wrong kind of data (such as a string), the compiler would generate an error. APIs are essentially lists of subroutines and the parameters they expect and the results they return.


Parse

This is a term for how a computer program "reads" some data. Essentially, parsing involves breaking data into smaller chunks and processing those. For instance, a sentence could be parsed into individual words, and each word could be translated into a command.


Property

A property is a variable that belongs to an object, as in, an object's property. It is usually used to store information or settings unique to that object. For example, a window has properties like width and height, which reflect and control the size of the window. A word processor's window might have a text property that contains the text of the window.


Pushbutton

A Pushbutton is a simple control design to execute a single action. For example, a program could have a "Save" button, which saves the current document. You can programatically set the font, size, and text of a pushbutton.


REALbasic

An easy-to-use object-oriented programming language for Macintosh computers. REALbasic was originally called CrossBasic and was written by Andrew Barry. It was redubbed REALbasic by REAL Software when they took over development. REALbasic's unique feature is its ability to compile the same programming code for Windows as well as Macintosh. REALbasic is similar to Microsoft's Visual Basic language.


Recursion

This is when a routine in a program calls itself. It is said to be recursive. Recursion is powerful and makes complex programming easier, but you must be careful: if your program recurses too much, it may run out of memory and crash. It is a good idea to think of each recursive call as a thread wrapped around a spool: a some point we reach the end of the thread and we must unwind the spool. The most famous example of a recursive algorithm is the QuickSort sorting algorithm. It basically breaks a list of items into smaller and smaller problems and recursively solves the smallest, then the next smallest, etc., until all the problems are solved and the list is ordered. From a programmer's perspective that's much easier than messing with loops, since you have no idea how many levels deep the routine will need to go to solve the problem.


Resource fork

The Mac OS has a unique file system in which files can have two parts to them. These two parts are known as the Data fork and the Resource fork. Generally, in a document file, only the data fork is used. The resource fork is designed for storing the resources of an application, such as menus, pictures, and text, but can contain multiple types of data. Other operating systems don't have a dual-fork file system and therefore can only access the data fork portion of the file.


Routine

See subroutine. The terms are interchangeable.


Scope

All variables have a limited "scope" of where they live. For instance, if you create a variable X within a subroutine, it is only available within that subroutine -- no other routine knows about X. Other routines could define their own X, but each would be unique to that routine. In REALbasic, because of its object-oriented nature, you can add a variable to a window or an object: then it's only available within that window or object. (Remember a window is an object just like everything else in REALbasic.) You can define variables as global by putting them inside a module -- this is a good idea for items that represent the state of your program (such as preference settings), but may not be for the user's data because global variables use memory whether or not they are actively being used. A word processor, for instance, will allow the user to create multiple windows -- it is best to tie each document with that window. That way if the window is closed, the data (and memory usage) goes with it. The same logic would apply to other types of programs.


Sprite

An animated graphic, usually a small object (like an icon of a spaceship) that travels over a background picture. Sprites are primarily used for games, but they can be used for anything that needs animating. A typical game may use dozens or even hundreds of sprites, all being animated seemingly simultaneously. (In reality, of course, sprites are animated one at a time, just so quickly that they all seem to move at once.)


String

A text data type. Strings are a series of characters (numbers, letters, symbols, etc.). In some programming languages, strings are limited in length, but in REALbasic they are limited only by memory (about 2 gigabytes). You could, for instance, load and entire novel into memory as a string and then search the string for a particular phrase.


Subclass

A subclass is a customized version of a class. It inherits all of the properties and characteristics (methods) of the original class of object, plus it can have it own unique features. For instance, you could make a subclass of an EditField object but make your version only accept numbers. It would do everything a standard EditField object does, except it would only allow the user to type in numbers. Once you have a subclass created, you can use the subclass any place you'd normally use the original object. To create a subclass in REALbasic, you choose "New Class" from the File menu, and with that new object selected, on the Properties palette you set the "Super" setting to the type of class you are subclassing (i.e. EditField). Then you can open the subclass and add properties and methods or overriding existing behavior. Subclassing is a vital aspect of Object-Oriented Programming and a fantastic time-saver.


Subroutine

A reusable function, procedure, or method usually designed to do a single task but do it well. For example, a program might have a sort subroutine, which alphabetizes a list of data. Different parts of the main program could call the sort routine as needed.


Syntax

The "grammar" of a computer language. Unlike human grammar, where incorrect usage implies a lack of education, incorrect grammar in computer programming will mean the computer won't be able to understand you at all. Put a plus where an equals sign is expected and the computer will cry "Syntax error!" and give up trying to understand your code. Most syntax errors are simple typos (like typing "endif" instead of "end if", but they can also be caused by attempting to assign incompatible data types (such as trying to put a picture into a variable expecting a number).


Syntax Error

This is a type of error generated by a programming language when it attempts to interpret your code and cannot understand what you meant. It is similar to an error in grammar, except that a computer is extremely unforgiving of minor mistakes. For instance, simply leaving off a parenthesis will cause a syntax error. Syntax errors are much simpler to debug than logic errors (errors in your program's structure).


Thread

A thread is a special sequence of code that is design to execute on its own, separate from the main program. Typically a main program hogs the computer's processing unit, not letting the user interact with the program while a complex or involved process is executing. If that task is put into a thread, the program can continue to respond and behave normally while the task is done in the background. As an example, imagine telling Word to open a 5,000 page document, or Photoshop to open a 100MB photo: you can't do anything else in those programs while those tasks are happening because the programmers didn't put those tasks into a separate thread. In contrast, most email programs are multi-threaded: you can edit or create emails even while your computer is downloading hundreds of new messages. Threads are powerful, but can be extremely complex. For instance, say you add a thread to your program to make it load that large document in the background. Great, but since the user can still work with your program, what if they quit or try to do something with that not-quite-yet-opened document? With threads, you must be more prepared to expect the unexpected as there can be unpredictable interactions between routines that expect data that isn't ready yet.


Timer

This is a special REALbasic object that executes periodically. The delay is set in thousandths of a second. When the allotted time has elapsed, the timer can execute just once, or reset itself and execute multiple times. A timer can be used for simple animation or to periodically update the status of a display.


Variable

Essentially a storage container. Literally it's a place in memory where that data is stored, but from the programmer's perspective, you just refer to the variable name to use the contents. In algebra, a variable is an unknown value (such as x). In a programming language, you can set x to equal 10 (or 20 or -59.3129 or whatever you want). In a sense, you are storing a number inside the variable x. You can then use x in your formula and the computer will perform the calculation as though x was whatever number it contains. Since x could change while the program is running, the computer uses the current value. In most modern languages, variables can be any name you'd like, such as myThing, pi, or ThisVeryLongVariable999WithNumbersInsideIt. In REALbasic a variable can be defined to contain only numbers, text (which could contain numerals), a sound, or even a picture. Obviously you won't do math on a picture, but you could print the picture that's stored in a variable. See Data type for more.


Visual Basic

Microsoft sells this programming environment for Windows. I know very little about it, but it's popular and supposed to be pretty good. Unfortunately, it's Windows-only, so it's of little use to Mac users.


About the Column
REALbasic University is a weekly instructional column on programming with REALbasic and is brought to you by REALbasic Developer, the magazine for REALbasic programmers.

Each week we answer select reader questions, and we're always open to ideas for future columns. Send your questions to . (Keep your questions simple and specific. General queries like "How do I write my own web browser?" will be neglected.) Your question won't be answered immediately, but will be answered in a future column. (If you don't want your correspondence published, just be sure to indicate that when you write. Otherwise it's fair game.)

About the Author
is an author, philosopher, graphic designer, photographer, film director, soccer fanatic, and programmer (among other things). He writes for MacOpinion, runs his own software company, Stone Table Software, which sells the revolutionary Z-Write word processor, and is Publisher and Editor of REALbasic Developer. He lives in Northern California with his cats, Mischief and Mayhem, and is rapidly running out of free time.

See the REALbasic University Archives


REALbasic University contents ©2001-2004 by Marc Zeedar and REALbasic Developer. All Rights Reserved.

Email This Article - Comment On This Article

.

Reader Specials

Server Racks Online:
Apple Xserve CompatibleServer Racks and Universal Network Racks
42U KVM Switch Solutions:
High-End Mac and Multi-Platform KVM Matrix switching solutions!
Digital Camera Online:
Great prices on Digital Cameras and accessories!
KVM Switches Online:
Great prices on Mac KVM Switches from the leading manufacturers!
LCD Monitors Online:
Great prices on LCD Monitors from the leading manufacturers!
LCD Projectors Online:
Shop online for LCD Projectors from the leading manufacturers!
USB 2.0 Online:
Great prices on USB 2.0 products from the leading manufacturers

Serious Business Software:
Accounting, Sales, Inventory, CRM, Shipping, Payroll & more!

KVM Switch solutions for MACs:
DAXTEN is a KVM switch, KVM extender and monitor splitter specialist for PC, SUN and MAC applications from name brand manufacturers - offices worldwide.

The "Think Different Store: The iPod Accessories Store - iPod cases, iPod mini, iPod photo, speakers, itrip, inMotion, Soundstage and all other iPod accessories

Earn Cash with the ThinkDifferent Store Affiliates Program

Need A Web Site?
Applelinks Web Hosting Starting at 19.95 a Month

iTunes_RGB_9mm

.

iTunes_RGB_9mm

Cool Mac Gear


iPod 1G-2G
iPod 3G
iPod 4G
iPod Mini
PowerBook-iBook
Keyboard Skins
Garageband