Introduction To REALbasic
(NOTE: This article assumes that you are a Windows developer with at least some programming
experience in VB5, VB6, or VB.NET.  However, if you are on a Mac, or do not have any experience
with Visual Basic, most of the information presented here will be relevant and useful)

Copyright© 2004 by Kevin Wilson



WHAT IS REALBASIC?

When I first discovered REALbasic, I asked the folks at REAL Software (http://www.realsoftware.com/) this question, and here's what they told me:

"REALbasic is an object-oriented, full-featured, easy-to-use development tool that is similar in many ways to Microsoft Visual Basic. The biggest difference (and advantage) is REALbasic's ability to compile the programs you've created so it will run on Windows, Macintosh, or Linux operating systems. This is especially advantageous if you are trying to roll out an application to the widest market possible."

REALbasic is a desktop application development tool very much like VB6 and VB.NET.  You can use it to create custom software that will compile to Windows, Macintosh, or Linux binaries.   REALbasic also has built-in support for such technologies as SOAP, XML, SSL, HTTP, SMTP, POP, UDP, ActiveX/COM, Databasing, as well as the ability to call external APIs (such as the Win32 API, or third party DLL files).  Such features and functionality make REALbasic a robust and flexible development environment.

The biggest advantage (in my opinion) of REALbasic is its ability to compile .EXE files that have NO dependencies (outside of standard system files that are already installed with the OS).  What that means is you can create an application using REALbasic, send it to the end user and you're done!   There's no worries about "DLL Hell," dependency file existence or versioning, packaging up and sending a ton of dependency files along with your program, etc.  I feel that .NET's requirements are its biggest downfall (at least when you're talking about desktop or client/server application development).  With .NET, you have to have the following things installed before you can even think about installing or running your application:

          TOTAL = 68 - 169 MB

What this means is that if you compile a little program that simply pops up a message box that says "Hello World," on some computer systems you will have to first install 170 MB worth of prerequisites and dependency files before you'll be able to run your little 10 KB .EXE file.  Ouch!  Especially if you are developing an enterprise level solution that will be rolled out over the internet to thousands of desktop computers (ranging from freshly installed Windows 98 systems with nothing on them, to Windows XP systems with all the latest technologies and security patches installed).  I recently had to do just that and it was an experience I hope I won't have to go through again anytime soon.

Now on the other hand, if you compile a little program that simply pops up a message box that says "Hello World" using REALbasic... you've got one .EXE file that is about 1.7 MB in size and requires nothing else to run.  That is power!

Microsoft's Visual Basic product line has been around for a while and has had time to really perfect their development environment.  When you compare VB.NET to the Windows version of REALbasic (which was just released about a year ago), REALbasic's IDE is a little less functional and "rougher around the edges."  However, it is still very similar, very functional, and is constantly being improved upon.


THE REALBASIC IDE:

"IDE" stands for "Integrated Development Environment."  As I said earlier, REALbasic has an IDE that is very similar to Visual Basic's IDE:

Snapshot - REALbasic IDE (GUI)

As you can see from the snapshot above, you have your "WYSIWYG" form editing interface, your controls window, your properties window, your menu editor window, your application browser window [A.K.A. - Project Window]  (lower right corner), and your menu system for more functionality and options.  A few things you may notice that are different from Visual Basic is there is a "Colors" window (lower left corner), and a "Tips" window (bottom).  Here's how it beaks down:

  

Form Editor:
The form editor is where most of your "RAD" (Rapid Application Development) comes from.  Using the controls window, you can "drag" controls onto your form and "drop" them whereever you'd like them to be.  You can then use the properties window to modify the form's attributes, as well as the attributes of the controls you've placed on the form.  Within a matter of minutes you can have a very rich, very intuitive user interface built and ready for the code to make it all work.   To add code to a user event on a specific control, menu item, or even the form itself, simply double-click and you're taken to the event handler of that control within the code editor window (see below for details on the code editor window).

Controls Window:
The controls window is where you get all the controls to place on the forms.  To put a control of your choice on a form, simply drag-and-drop it from the controls window to your form.  You'll notice as you drag the control that lines will appear on the form.  These are "guide" lines that automatically appear to help you line up the controls you place on your form.  This is extremely helpful and something that I wish that Visual Basic would adopt.  I've spent too much time in the past eye-balling controls to try to make sure they are lined up correctly.  Sometimes I got it right, sometimes I didn't.   With REALbasic's control guide lines, there's no guess work -- you know at a glance if things line up or not.  However, if you don't want to use the guide lines and you just want to place the control freely (with no snap-to functionality), simply hold the <CTRL> key and you can place the control "freehand" just like in VB.

Also, just like in Visual Basic, you can move controls around the form by selecting them, holding the <SHIFT> key, then using the arrow keys on your keyboard to move them around.  This is especially handy when it is hard to move controls around with the mouse because the form is very complex and/or has a lot of controls on it.

If you would like to add an ActiveX/COM control to your form, REALbasic can do that as well.  Simply select the "Add ActiveX Component" from the "File" menu and select which one you would like to add to your project.   Keep in mind that you may have to make use of the "OLEObject" class in conjunction with the "OLEParameter" class in order to make certain method calls that required ByRef, or BLANK parameter values.  The following example code demonstrates this point:

* NOTE: This is the REALbasic implementation of the "Node Property Example" found on Microsoft's MSDN web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cmctl198/html/vbpronodesx.asp
It demonstrates how to add "Node" objects to the "TreeView" control found in the "Microsoft Windows Common Controls" [MSCOMCTL.OCX or COMCTL32.OCX].

1) Select "Add ActiveX Component..." from the "File" menu in REALbasic

2) Select "Microsoft TreeView Control" from the "Controls" tab in the dialog that appears

3) Drag-and-drop a TreeView control from the controls window to a blank form.  The control's default name is "TreeView1"

4) Add the following code to the "Open" event of the form:

 
Dim tvwFirst    As Integer = 0
Dim tvwLast     As Integer = 1
Dim tvwNext     As Integer = 2
Dim tvwPrevious As Integer = 3
Dim tvwChild    As Integer = 4
 
Dim nodX         As OLEObject 'Node
Dim objParam     As OLEParameter
Dim arrParams(3) As Variant
 
objParam = New OLEParameter
objParam.Position = 1
objParam.Value = Nil
arrParams(0) = objParam
 
objParam = New OLEParameter
objParam.Position = 2
objParam.Value = Nil
arrParams(1) = objParam
 
objParam = New OLEParameter
objParam.Position = 3
objParam.Value = "R"
arrParams(2) = objParam
 
objParam = New OLEParameter
objParam.Position = 4
objParam.Value = "Root Node"
arrParams(3) = objParam
 
nodX = TreeView1.Nodes.Invoke("Add", arrParams)
nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
nodX.Invoke "EnsureVisible"
TreeView1.Style =
4 'tvwTreelinesText
TreeView1.BorderStyle =
1 'vbFixedSingle
 
Exception Err
As RuntimeException
 
MsgBox "Runtime Error: " + CStr(Err.ErrorNumber) + " [" + Err.Message + "]"

 

 
Properties Window
:

The properties window is where you can view or edit the attributes of your forms, controls, menus, and even your application.  You can rename your objects, set the color of objects, and specify how the objects should (or shouldn't) behave at run-time.   The layout of the properties window is similar to that of VB5, VB6, and VB.NET, but there are some differences.  For example, properties that are declared as BOOLEAN are not represented with a "True" / "False" drop-down in the properties window.  Instead, they are represented by a CheckBox (checked for TRUE, unchecked for FALSE).  Also, all properties that are declared as STRING will have a little CommandButton next to them with three dots in it.  If you click on that little CommandButton, you will be presented with a multi-lined TextBox entry field to enter in any value you like.  Other than that, numbers are represented by number values, strings are represented by a string, and so on.

One thing to be careful of is if you have a property with a string value that is too long, it will wrap in the properties window.  For example, lets say the value of the "Name" property of a control is very long (i.e. - "txtThisIsWhereTheUserEntersTheirName"), only the first few characters of the name will show in the properties window, the rest will "wrap" to the next line and most likely will not be visible.  Because of this, if you click once on the "Name" property within the properties window, then press <END> to go to the end of the value, then hold <SHIFT> and press <HOME> to highlight the entire string value, and then press <DEL> to delete it -- only the first several characters will be deleted because the second line of the text that "wrapped" is not selected.  The way to get around this is to double-click on the value, then press the <DEL> key.  The only time this won't work is if there are spaces in the text value (in which case you'll have to press the <DOWN> key to "page" through the "wrapped" text value and delete as needed).

Menu Editor:
The menu editor in REALbasic is similar to the one in VB.NET, but nothing like the one in VB5 or VB6.  You have the ability to select a menu item, rename it, specify its property values via the properties window, and drag-and-drop it to wherever you would like it to be.  This makes the menu editor in REALbasic far superior to the one in VB5 or VB6, but it is not quite as intuitive as the one in VB.NET (but it's close).

The one thing that is a little bit clumsy/annoying about the way menus work in REALbasic is how you put code behind the menu items you create.  Once you create a menu item and assign the proper attributes to it, you have to select "New Menu Handler" from the "Edit" menu (or press CTRL+ALT+H) and then specify the name of the menu item you just created.  Once you've done this, then it finally takes you to the event handler for that menu item.  It would be really nice if you could simply double-click on the menu item and be taken directly to the event handler of the menu item you double-clicked.

Application Browser:
The application browser window shows you all of the Forms, Modules, Classes, Class Interfaces, and Resources Files that are into your project.  Your application also shows up in the application browser (the default name is "App").  By selecting these objects, you can specify their property values via the properties window.

Keep in mind that you can add resource/multimedia files to your project as Resource Files by selecting the "Import..." menu item from the "File" menu in REALbasic (or by simply dragging and dropping them onto the application browser window).  Resource files compile right into the .EXE when you build your application.   Once added, you can gain direct access to them by simply spelling out the name of the resource in your code, and then calling the appropriate methods or properties (i.e. "Play" for sound and music files, "Height" and "Width" for picture and movie files).  Note that if you double-click on a resource file within the REALbasic IDE, it will attempt to display or play the file.

I have successfully added the following multimedia files to a project as a resource:

MID - MIDI music file
WAV - WAVE sound/music file
MP3 - MP3 sound/music file
GIF - "Graphics Interchange Format" picture file
JPEG - "Independent JPEG Group" picture file
PCT - "QuickTime Picture" file
PNG - "Portable Network Graphics" picture file
BMP - "Windows Bitmap" picture file
TIFF - "Tagged Image File Format" picture file
MOV - "QuickTime Movie" file

The following multimedia files simply show up as an "unknown file" within REALbasic:

ASF - "Windows Media Player" sound file
AU - "NeXT/Sun (Java)" sound file
SND - "NeXT/Sun (Java)" sound file
RA - "Real Audio" sound file
RM - "Real Media" sound file
SMP - "SampleVision" sound file
VOC - "Creative Labs VOC" sound file
WMA - "Windows Media Audio" sound file
PSD - "PhotoShop Document" picture file
EPS - "PhotoShop EPS" picture file
ICO - "Winodws Icon" picture file
CUR - "Windows Cursor" picture file
PCX - "PC Paintbrush" picture file
PIC - "QuickTime Picture" file
RAW - "Raw Data" picture file
TGA - "Targa" picture file
RLE - "Run Length Encoded Bitmap" picture file
SCT - "Scitex CT" picture file
MPEG - "MPEG" movie file
QT - "QuickTime Movie" file
RAM - "RealPlayer Movie" file
RM - "RealMedia" movie file
SWF - "Flash Movie" file
WMV - "Windows Media Video" movie file

When I tried to play the following multimedia files (after adding them as resource files), the REALbasic IDE crashed with a memory exception:

RMI - "MIDI" music file
AVI - "Windows Animated Video" movie file  (I tried with multiple compression methods, as well as NO compression)
ANI - "Windows Animated Cursor" picture file

The following example code demonstrates how to add a multimedia resource to your project, then make use of them via code:

1) Drag-and-drop a BITMAP file named "MyPic.bmp" into the REALbasic application browser  ~or~
    Select "Import..." from the "File" menu and select the file "MyPic.bmp"

2) REALbasic will add "MyPic.bmp" to your project as an PICTURE resource named "MyPic"

3) Add the following code to the "Paint" event of the project's default form:

g.DrawPicture MyPic, 0, 0

4) RUN the project.   You'll notice that the BITMAP is now painted onto the background of the form and stays there because everytime the form refreshes/repaints, the image is re-drawn on it.   This gives you the same functionality as setting the "AutoRedraw" property to TRUE on a PictureBox or Form in VB5 and VB6, then setting the "Picture" property equal to a loaded image file.


1) Drag-and-drop a WAVE file named "MySound.wav" into the REALbasic application browser  ~or~
    Select "Import..." from the "File" menu and select the file "MySound.wav"

2) REALbasic will add "MySound.wav" to your project as an SOUND resource named "MySound"

3) Add the following code to the "Open" event of the project's default form:

MySound.Play

4) RUN the project.   You'll notice that when the form comes up, your sound will play


1) Drag-and-drop a QuickTime MOVIE file named "MyMovie.mov" into the REALbasic application browser   ~or~
    Select "Import..." from the "File" menu and select the file "MyMovie.mov"

2) REALbasic will add "MyMovie.mov" to your project as an MOVIE resource named "MyMovie"

3) Add a "MoviePlayer" control to the project's default form.  The control is named "MoviePlayer1" by default.

4) Add the following code to the "Open" event of the project's default form:

MoviePlayer1.Movie = MyMovie
MoviePlayer1.Play

5) RUN the project.   You'll notice that when the form comes up, your movie is displayed and starts playing
 

 
Colors Window:
The colors window allows you to specify up to 16 "favorite" colors to be used throughout your project.  That way, if your application has a standard set of colors it uses, or has a color theme to it, changing all the GUIs of your program to match that color set or theme is quick and easy.  You select a "favorite" color by clicking on the square you want that "favorite" color to reside in.  You add a "favorite" color to a form or control by dragging and dropping it onto the "BackColor" property (or any other property that evaluates to a "Color" data type).

Tips Window:
The tips window will automatically populate with tips, hints, suggestions, and code syntax as you go through the process of developing your application.  This can be extremely helpful when you are checking code syntax, or if you are simply coding away and see a tip pop up about functionality you didn't know existed.  I wish that REALbasic had "ToolTip" style pop-up IntelliSense and syntax prompting (like VB5, VB6, and VB.NET), but this is a satisfactory alternative.

 

Keep in mind that at this point in time (May, 2004 / RB v5.5.1) you can only develop software with Windows, Mac Classic, or Mac OSX.  The different development environments look a little different because of this, but they all have the same syntax, the same functionality, and the same "look and feel."  Here's what I mean:

Windows Version:
Windows
Mac OSX Version:
Mac OSX
Mac Classic Version:
Mac Classic

 


UNDER THE HOOD:

Now that we've taken a look at REALbasic's IDE and discussed a few things that it can do, lets pop open the hood and see what makes everything run!  When you double-click on a form or a control, you will be brought to the event handler that responds to the default event of that form or control.  You will see the code window and it will look something like this:

Snapshot - REALbasic IDE (code)

Here you see that there are a few things that are just like Visual Basic, and a few things that are a little different.  First off, you'll notice that the syntax is almost identical.  In fact, if you add a module I wrote called "modVisualBasic.xml" (which I highly recommend for any project big or small), you have access to almost all of the same built-in functions, constants, and shortcuts that VB5 or VB6 has.  REALbasic gives you "IntelliSense" and "auto code complete" just like Visual Basic does, but it does it via a slightly different "ListBox" style pop-up.  Note that in order to see this list, you have to press the <TAB> key on your keyboard (it is not displayed automatically like in VB).  Also, you have syntax information displayed in the tips window (as I mentioned earlier).   Between these two things, it will be fairly rare that you'll need to open up REALbasic's built-in help system to double-check your syntax.  However, if you do need to double check syntax or look up functionality, the built-in help has a lot to offer.

Something else that you'll notice is just like Visual Basic -- you can grab the little bar at the top of the code window and drag it downward to "split" the coding window.  This way you can edit the contents of two functions at once.  Visual Basic does this, so it's nice to see it here because it's a useful feature.  However, REALbasic took it one a step further!   Not only can you have two code windows open at a time, you can have as many as seven (or more if your screen will fit them all) open at a time.  This makes things even easier if you choose to take advantage of this feature (or you can ignore it and simply have one big code window).  One thing to note is that REALbasic only allows you to edit the contents of one Function/Sub/Note per coding window.  You can have multiple coding windows open at a time by splitting them, but Visual Basic allows all the code to be open at once so you can scroll down through it all (which I rather like).

Another thing you'll notice that is a little different is the "object browser" to the left.  This allows you to see what objects and events are available within the current Form, Module, or Class.  Events that have code behind them are bolded to make it easier to tell where you've put your code.  In my opinion, this is a little better than Visual Basic's drop-down object browser at the top of the code window.  Having a visual representation of all the objects and events within a given Form, Module, or Class makes it easier to find things "at a glance."

  

When you get right down to it, REALbasic is actually more like VB.NET when it comes to code and syntax, but is more like VB5 or VB6 when it comes to the IDE.  The reason I say that is VB5 and VB6 are not "Object Oriented" programming languages, they are "Object Based" programming languages.  VB.NET and REALbasic, on the other hand, are true "Object Oriented" programming languages.  Here's the definition of OOP:

"The use of a class of programming languages and techniques based on the concept of an 'object' which is a data structure (abstract data type) encapsulated with a set of routines, called 'methods,' which operate on the data.  Operations on the data can only be performed via these methods, which are common to all objects that are instances of a particular 'class.'  Thus the interface to objects is well defined, and allows the code implementing the methods to be changed so long as the interface remains the same.

"Each class is a separate module and has a position in a 'class hierarchy.'   Methods or code in one class can be passed down the hierarchy to a subclass or inherited from a superclass. This is called 'inheritance.'

"A procedure call is described as invoking a method on an object (which effectively becomes the procedure's first argument), and may optionally include other arguments.  The method name is looked up in the object's class to find out how to perform that operation on the given object.  If the method is not defined for the object's class, it is looked for in its superclass and so on up the class hierarchy until it is found or there is no higher superclass."  *

Essentially, in order for a programming language to be considered "Object Oriented," it must be able to do the following things:

VB5/VB6 doesn't quite qualify as an OOPL:

VB.NET does qualify as an OOPL:

REALbasic does qualify as an OOPL:

For further information on similarities and differences between VB5, VB6, VB.NET, and REALbasic, I suggest going to a web site called "VB/RB Rosetta Stone" (http://www.kode-fu.com/rosetta/).  It does a great job of putting these (and other) programming languages side by side and comparing them.

 


CONCLUSION:

In conclusion, REALbasic has a lot to offer, and is a great programming language for the money ($99.95 for the Standard Edition, $399.95 for the Professional Edition - goto http://www.realsoftware.com/store/standardvspro.html to compare them), especially when compared to VB.NET for $109.00, and VB.NET Pro for a whopping $1079.00.  REALbasic shines brightest if you need a development package that is much like Visual Basic, but gives you the ability to compile your program (with no dependencies) for Windows, Mac, or Linux.

If you have not yet learned Visual Basic but have wanted to, I might suggest picking up REALbasic instead.  I would also suggest picking up REALbasic if you know VB and are interested in something new, something challenging, and/or something exciting.  However, if you are already in the middle of a development cycle with an application, I would not suggest converting it to REALbasic.  The reason I say that is because while VB and RB are very similar in many ways, they are not close enough to where you could copy your code from your existing VB project directly into RB and hit the COMPILE button.  The "VB to RB converter" utility that is included with REALbasic helps, but realistically speaking, you're going to have to rewrite and tweak the vast majority of your VB code to port it over to RB.  Time is money.  As far as how REALbasic would stand up to Visual Basic for an enterprise level "Windows only" project, that depends.  You would have to sit down and look at what REALbasic and Visual Basic have to offer, and decide which is best suited for your project.

Also, keep in mind that when compared to the Microsoft Visual Basic product line, REALbasic for Windows is a little rough around the edges.  This may not be the case with the Mac version of REALbasic -- I don't know because I don't use Mac.  But the team at REAL Software is always working to improve it, and has proven to be very receptive and responsive to user feedback.  I myself have reported bugs or requested features in the past and they have been implemented and released within a matter of weeks.

All and all, I give REALbasic two thumbs up and it is a welcomed addition to "The VB Zone."  Bravo, REAL Software!   Keep up the good work.

 
 
- Kevin Wilson
  (author and creator of "The VB Zone" www.thevbzone.com)

 


* Source = "TheFreeDictionary.com"