Welcome to the REALbasic Developer Magazine Beginner's Corner!
Issue: 1.2 (October/November 2002)
Author: Thomas J. Cunningham
Article Description: No description available.
Article Length (in bytes): 9,230
Starting Page Number: 28
Article Number: 1113
Related Link(s): None
Excerpt of article text...
This month's column will focus on some of the beginning computer science issues that need to be understood by all programmers. This knowledge will help you to learn not only the RB language better, but allow you to code with more confidence. Let's start with the concepts of variables and data types.
Variables and Data Types
Computers "think" differently than humans. Of course, they really do not think at all, but manipulate memory. If I ask you to tell me what two times four equals, and you were awake in the second grade, you would say eight. Now if you get right down to the nitty gritty here, one may ask, "What is two? What is four? What is times?" These would be fair and honest questions at their most fundamental and abstract levels.
This kind of talk may seem silly to you (or perhaps profound!), but these are the type of issues we have to deal with when we program a machine. Our Mac knows what a two is and what times "means," but we have to tell it, explicitly, what we are trying to accomplish. This explicitness comes from declaring variables, by assigning names to them, and by declaring a data type. This is the way we tell our computer how to allocate so much of its memory to perform the task at hand.
The manner in which a computer uses memory takes up volumes in the libraries of the world; fortunately, RB takes care of most of the chores of memory juggling for us. An example snippet of code here will make things a bit easier to explain. If you want, drag a pushbutton into a Window1 of a new project, double-click it, and in the action event of the pushbutton's code editor type this:
Dim a, b, c as integer
...End of Excerpt. Please purchase the magazine to read the full article.