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

Introduction to REALbasic for the Mac

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

Did you find this tutorial especially helpful? It's reasonable to assign value to the information we consume.
Consider compensating Thomas with a small amount ($5) for his efforts!

space spacespace
space space
Lesson 9: Writing Code ...
by Thomas J. Cunningham

  space space

A Little More Coding ...
9. The Code Editor - continued ...

We are now at a point in our little project where we need to add and modify an EditField. Double-click Window1 in the project window to reveal our main window. Drag an EditField class from the Tools Window to our main window. Drag the corners to make it about 130 pixels wide. The Properties Window will reveal to you the EditField1 width. My project looks like this:

* Please see note to the right *

Double-click the editfield to reveal the Code Editor for our newly created Control.


There are eleven different Event Handlers for the EditField Class. We will, as before, concentrate our code in the Open Event. Referring to Chapter Five you will remember that we are going to alter two properties.

    In the Open Event Of EditField1 Type This:

  • // I want to place the words (string) "Hello World!"
    // in to the editfield
    Window1.EditField1.Text="Hello World!"

The one word property name is all we need to accomplish this task. Please confirm this by finding the text property of the editfield class in the on-line reference (Command-1). Run you project to make sure everything is the way you want it.

Our next and last task is to change the text color of hello world to a color other than black. Let's go for red.
Color, is frankly a whole other subject in computer programming with REALbasic. To cut to the chase, we tell the computer what color we want by telling it how much red, green or blue we want (RGB). The values run from 0 to 255. Each of these colors are "mixed" to produce a final color. Don't worry about it here if this color stuff doesn't sink in, OK ? Good - No Worries !

    In the Open Event Of EditField1 Now Reads:

  • // I want to place the words (string) "Hello World!"
    // in to the editfield
    Window1.EditField1.Text="Hello World!"
    // I want to change the text color to red !

Run the project and view your nice large red letters.

Summary Chapters Six thru Nine
You've come quite a distance in these last four chapters - good job ! We have covered a lot of principles for you to build upon. I have not referred to our initial house concept in quite a few chapters, but I hope you can see by now how the analogy applies to computer programming in REALbasic. A tree becomes lumber, lumber the material of a creative mind becomes a home.
I like to relate the story of my son when he was around six. Give him a hammer, some nails and wood and he was totally happy building something only he knew in his head. He is twelve now and one Saturday a while ago him and his buddy took a lot of old lumber I had laying around the yard and had built a very cool (although not terribly safe) skateboard park of sorts in our back yard, with ramps and stuff. I was a very proud dad. This is sort of the way you progress as you hack thru code by trial and error.
Frankly, up to this point we really have not even gotten in to any significant coding exercises. I have tried to stay to a simple regimented tutorial here with a few more advanced clues thrown in to keep you hungry for more. I also hope and expect that you have diverged from this project too ! In other words, if you haven't already, start hacking out some code and experiment. What have you got to lose ? Our lumber (code) is free ! Ok, maybe you'll freeze your machine (Command-Shift-Period is your escape), big deal. Your Microsoft programs probably already do that ! (just kidding Mr. Gates).
I think that if you have gone through all nine chapters, that you should be totally enthused about the creative fun and accomplishments that REALbasic can bring you.

If not, go back to TV. ; - )

That's It For Now ! I have skateboard parks to code ....

P.S. I could really use your input - what subject would you like to have next ?


Your REALbasic (RB) Learning Library and Reminders

- Please Notice !
Take a look at the first screen shot of my version of this tutorial project. Your project window may look a little different of course. One difference might be the type of font you see for the text in the window's title and the statictext. My computers Apple-Control Panels-Appearance-View Font is set to Helvetica. One of the properties of all your Controls in REALbasic is TextFont, and it is set to default at "System". So, since we have not altered this property during our tutorial, you see it as my computer wants it too. Big deal you say. It might actually. If this was a genuine application and one of my users had their computer set-up with a large type font, some of my applications text might not fit where I designed them to fit.
One of the area's I clean-up in my projects is to set the TextFont and TextSize to something that I know will look good (at least to me!) and fit properly. By setting these properties in REALbasic, they override your end users settings.

- Color
When it comes to color, I use the RGB (Red, Green, Blue) model here. There are two other models that REALbasic recognizes. I find RGB easier to use and over all better for beginners. Our example uses 255 portions of red, the maximum amount and zero amounts of green and blue. Change the numbers and see what colors you can mix-up.



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

Find This Useful / Not ? Email Me :

Copyright 2001,Thomas J. Cunningham