Real Logo
REALbasic Home
X
Thank you for trying this tutorial ... It is not associated with REAL Software.     powered by ... a desire to share
space


Introduction to REALbasic for the Mac


space
space space
space Contents
What You Should Know
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9

My RB Samples
space spacespace
space
space
space space
Lesson 5: A Simple Example ...
by Thomas J. Cunningham

 
  space space

Getting to Know REALbasic ...
5. Building Upon Our Concepts.

Our Simple First Project:
Lets tie up some of the points raised earlier by building a very simple "house" with two classes, a statictext class and an editfield class.

(1) Double-Click the REALbasic Icon.
green cube
A new project appears, "untitled". To the left you see the "Tools" window palette. All of those letters, lines, watches, etc. are classes that RB has built for you. They are ready to be dragged to your main project window. In the center, you see your Window1, this is the house where we will add our two classes. To the right, you see a properties window. The properties you see listed happen to be for Window1 itself. Yes, the window is a class too!

screen shot
Click on photo to enlarge.

2) Close the window1 "untitled" window. Command-W.
Notice that the properties window is blank. If you have no classes, then you have no properties! Makes sense to me.
Our house window goes away to reveal our "project" window. This is a window that RB uses to organize the pieces for your program. You see two default listings, Window1 and Menu.

3) Double click the Window1 listing in the projects window.
Our Window1 appears again. Feel free to move it around to see everything clearer.

4) In the Tools Window (on the left side), place your arrow cursor over the "A" in the upper left corner. The arrow changes to a hand. This is a nice RB user interface feature. The hand "tells" you you can grab and move it. Hold your mouse down and grab the "A". Drag it to somewhere in the Window1 window and drop it by releasing your mouse. The words "Label:" appears with a box around it. Label is the default name.
Congratulations, you have just added a StaticText Class to your window. With the statictext class still highlighted, notice our properties window, to the right, now shows what properties our statictext has. These are the default values that RB designed in to this Class. Notice also that our statictext properties window is broken down in to four kinds or types of properties, ID, Position, Appearance and Font.
A StaticText Class is just as it sounds, text, words. Some of its properties should seem obvious to you. For instance, Font, Size.

5) Click anywhere in the window to deselect our newly created statictext class.
Now what do you see? Yep, you just clicked on the window and its' properties again show up in the properties window. Lets add our other class, editfield, to our house.

6) In the Tools Window Palette, click once on the third column from the right, Fourth row down icon, and drag it to Window1.tools Drop the Editfield anywhere you like. It too will remain highlighted with its associated properties displayed to the right in the properties window.
The Editfield allows the user to enter text, words and numbers.
Our two classes behave just like objects in a drawing program. You can click on them and reposition them anywhere within Window1. You can grab their little black corner handles and resize them too.
Before we "run" this project, lets change one property parameter for each of our three Classes.

7) Window1 class first. Click on an open space in Window1. Under the appearance kind in the properties window to the right, find "Title" and just to the right of title you will see "untitled". Highlight untitled, your cursor will change to an "I-Beam" indicating you can edit this text and type " My First Window", hit the enter key.
You now will see that Window1's title property has been changed to "My First Window". We might write what we have just done either as:
(1) ClassName.Property=Parameter or
(2) Window1.Title="My Window"
Listing number one above is a general description of the Syntax that the RB language uses.
Listing number two is the actual code you could use to set the title property of the window during runtime.
Let's proceed to our StaticText class.

8) In your My First Window, click on "Label:". In the properties window, under the Font Kind, find "TextSize". To the right of this change the 12 to an "18" and hit enter key. You now see Label1 in a larger font size.
We might write what we have just done either as:
(1) AWindow.Class Name.Property=Parameter or
(2) Window1.Statictext1.TextSize=18
And finally lets proceed to our third class, the EditField class.

9) I lied earlier, we are going to add two properties to our Editfield. Click on the EditField box so that you see the black squares in each corner. Next, type " Hello World ! ". You just added the Initial State Text property to this Editfield Class. Resize the box by dragging the right side out if you can not read all of what you typed.
While the Editfield box is still highlighted, find the TextColor - Appearance property area. You see a black box. Click on this area. Depending on what Mac you have, you will see the color selector window. Pick a color, something other than black please. Press OK. What ever color you chose appears in the previously colored black box.
Now don't panic, your letters in the editfield are still black. Why? No big reason really, RB's IDE only shows black, the text color will show during run time. Run your project (Command R) and enjoy your beautiful new Mac program (Our House Remember?). Oh by the way, you Command Q or File-Quit to quit the program from running. This will not quit REALbasic, just your program.



Chapter 6
 


Your REALbasic (RB) Learning Library

Syntax -
- Syntax refers to how you can communicate with the REALbasic language. Remember that a computer only knows what it knows, so you have to communicate with it in a manner that it understands. Think of syntax as the nouns and verbs that you use in everyday English. Unlike human beings who can understand either "John, run!" or "Run John !", RB can not.
RB uses a dot notation between nouns and verbs.

- REALbasic has an excellent on-line help system. While you are in the IDE, simply hit Command 1. Look up our StaticText and EditField classes from this exercise to learn more about them.
- By the end of this little exercise, you have really accomplished a heck of a lot. You have a window, that you have named, it has some words in it and it has a box that you can type more words in to. You have done all of this and you have not written one line of code! You could build this project (Command M) and EMail it to your friends who would be amazed and dazzled by your incredible computer skills. This is very cool and not trivial !

- Be sure and start changing all of the properties listed for the StaticText and EditField Classes once your through with this lesson. Have fun!

- If per chance during your messing around your program freezes or does something weird you can also escape or quit by :
1) Command - Shift - Period. or
2) Click on the Projects window in the background, then Command K (kill) or Menu-DeBug-Kill.

____

  1 | 2 | 3 | 4 | 5 |   6 | 7 | 8 | 9 |


Find This Useful / Not ? Email Me : mauitom@maui.net

Copyright 2001,Thomas J. Cunningham