TweetFollow Us on Twitter

First REALbasic

Volume Number: 15 (1999)
Issue Number: 11
Column Tag: Getting Started

REALbasic

by Erick J. Tejkowski

Develop powerful Macintosh and Windows applications in minutes

Introduction

After spending hours upon hours trying to perfect that "Hello, World!" code you tediously typed into your favorite C++ compiler, you discover that a semicolon was out of place. There must be a better way, you think. There is a better way and it goes by the name of REALbasic.

REALbasic is a full-fledged visual development environment for 68k and PPC Macintosh computers. With it you can construct sophisticated user interfaces, enter some code, and compile Macintosh and Windows applications in a matter of minutes. REALbasic is truly a revolutionary development product. In fact, REALbasic was named the Apple Design Awards Product-of-the-Year for 1999. This article will give a brief overview of REALbasic, the IDE, and show you how to write your first application in only minutes.

Features

REALbasic is an Integrated Development Environment (IDE), which is just a fancy way to say that it has all of the necessary components to build standalone executable applications. Within REALbasic, you can build the interface for your application, enter the necessary code, test and debug the code, and finally build the application. Although this sounds a lot like other popular development environments, and in some ways it is, REALbasic takes your development to new heights. The beauty and elegance of REALbasic stems from the fact that it is a visual environment. What this means to the beginner programmer is that you will already feel very familiar with REALbasic the first time you use it. It behaves just like many other Mac programs you have used before. More importantly, you construct much of your application by visually building it within REALbasic. Remember the first time you gasped in awe at the amazing ease and speed you altered your favorite applications with ResEdit? REALbasic continues in this tradition. In the "old days" programmers had to build applications using only code. Resources helped alleviate some of this tedium by using a graphical interface in which to construct parts of an application, but code was still required to make use of the resources, or for that matter to even make the resources appear on the screen. REALbasic removes much of the need to code the interface of your application. Instead, an application is built with drag-and-drop ease.

The first version of REALbasic included support for standard interface elements, QuickTime playback, TCP sockets, Serial controls, and a plugin architecture. The second and current version improves on each of these areas as well as adds an exhaustive list of new features. To begin, REALbasic 2 adds eight new Appearance-savvy controls, new QuickTime functions, including compression and effects, improved Internet support, and expanded Apple Event support.

Perhaps the most clever of the new features is control binding, which allows you to bind two controls together. This affords you immediate functionality without writing a single line of code! For example, an EditField and a ListBox can be bound together, resulting in the EditField automatically displaying the data from the selected row in the ListBox.

International users of REALbasic will be pleased to know that REALbasic now supports double-byte characters and complete localization features, which allow you to build applications in a variety of languages with the click of a mouse.

The Professional version of REALbasic also includes a single-user relational database engine and database connectivity to 4D Server, Oracle, Microsoft SQL Server, OpenBase, dtf, PostgreSQL and any ODBC-compatible database engines. If all of this weren't enough, you also get a Windows 95/98/NT compiler. Compile Windows applications right on your Mac desktop without writing any additional code. Wow!

The IDE

The heart of the REALbasic IDE is the Project Window. The Project Window is a place to organize the various parts of an application. These parts might include windows, a menu, picture files, or any number of other items, which will be discussed shortly. Figure 1 shows a Project Window with default items. This is what opens when you first start REALbasic.


Figure 1.The Project Window.

REALbasic begins with a Menu and a Window in a project, which might be considered the bare minimum for a Macintosh application. Adding items to a project can be accomplished in different ways. First, use the FILE menu to add Windows, Modules, Classes, Pictures, Sounds, Resources, and Databases to your project. Some menus create new items in your project, while other items are added by importing them into REALbasic. REALbasic also fully supports drag and drop. To add a picture file to your project, for instance, you can drag a picture file directly from the Finder into the REALbasic project.

Many of the items in your project can be created and edited directly within the REALbasic IDE. Since REALbasic gives you a window by default, you need not add one to start. Simply double click Window1 in the project window. A window will open on your desktop. This is called the Window Editor. You can now add controls to your window. Controls are found in the Tool Window. Simply drag a control from the Tool Window to Window1. Go ahead and try it. Drag a PushButton from the toolbar to the open window. You will notice that the PushButton appears highlighted upon addition to the window. This means that the control is selected and its properties are currently being displayed in the Properties Window. The properties window displays the various attributes of a particular control. To alter the text on the PushButton, select it and change the Caption property in the Properties Window.

Now, add a StaticText control. The control appears as a large capital letter "A" on the toolbar. This control is a simple text control that does one thing (drumroll...) it displays text. By default, the text property is "Label:". Select the StaticText control you have added to the window and change the "Text" property to read "Hello, World!".

The IDE also has a Colors Window. This is a small palette to store frequently used colors. Figure 2 demonstrates the Window Editor, Property Window, Colors Window, and Project Window.


Figure 2.Some of the the various Editors in REALbasic.

Now that a control has been added to the window and the properties of that PushButton edited, it is time to add code. Either double-click the PushButton or select the PushButton and hit the "Return" key. A window called the Code Editor opens displaying events on the left side of the window and code on the right. Since the PushButton was selected, you are instantly transported to the Action event of PushButton1. The code that appears within the Action event of the PushButton will be executed during runtime when a user clicks the PushButton. For now, just enter the following code:

	if staticText1.text="Hello, World!" then
		statictext1.text="My dog has fleas."
	else
		staticText1.text="Hello, World!"
	end if

Figure 3 shows the Code Editor with code in the "Action" event of PushButton1.


Figure 3.The Code Editor.

Believe it or not, you have just completed your first application. To test your work, select the Debug:Run menu. You will see your application. Click the button and watch the text change. If your application doesn't work the first time, be calm. REALbasic should show you where the error is. Recheck your code for typos and try to run it again. When you are finished testing the application, select the File:Quit menu.

Having designed, coded, and tested the application; the final step is to compile it into a standalone application. Select File:Build Application. The Build Application window appears. Final settings for the application are made here. Select Macintosh format, include 68K code, and enter a name for your application. For example, enter "My First RB Application". Click "OK" and REALbasic builds a final application.

Now that you have learned the basics of putting together a simple application, let's move on to something a bit more complex, but ultimately more useful. Learning to program is a lot more fun if your program actually does something. Keeping this in mind, I chose some code from Geoff Perlman at REAL software. The example we will build is a movie editor of sorts. The finished application will allow you to import a QuickTime movie, designate different scenes in the movie, and finally reorder the scenes to view them in a different order. Geoff informs me that a method similar to this is used by George Lucas himself when editing films.

Creating the Interface

Before starting this project be sure to download the latest version of REALbasic. Version 2.1a19 was used to build this project.

The Movie Editor project makes use of three different windows. A movie editor window, a clip editing window, and of course an About Box. Start the REALbasic application. You will be presented with a new project that contains a window called "Window1" by default. Select this window and adjust the properties to match Figure 4, including the name that should now be "MovieEditor".


Figure 4.The MovieEditor window properties.

Now that the MovieEditor window has been made, it is time to add controls. Drag a ListBox control from the toolbar onto the MovieEditor window and change the name of the ListBox to "ClipList" and the remaining properties to match Figure 5. The "ClipList" will display each of the clips you will make. This is also where you will be able to rearrange the order in which the clips play.


Figure 5.ClipList Properties.

For the next step, add four buttons to the MovieEditor window. Enter the names "RecordButton", "PlayButton", "UpButton", "DownButton" for each of the buttons. Then, change the remaining properties of each button to reflect the settings shown in Figure 6. Be sure to change the Caption property of each button to "Record", "Play", "Up", and "Down" respectively. In addition, disable all of the buttons with the exception of the "Record" button by turning off the Enabled property.


Figure 6.The MovieEditor PushButton settings.

Next, drag a MoviePlayer control onto the MovieEditor window and set the Top property to 201 and the Left property to 13. Select the Controller setting for the Controller property in the Behavior portion of the MoviePlayer properties. Lastly, drag a Timer control onto the MovieEditor window. Set the Mode to 0 (zero) and the Period to 5. Timer controls can be located in any position on the window, because they are invisible controls. Two more controls have also been included in the sample application. These two controls are GroupBox1 and GroupBox2. In this example, they are strictly for improving the look and layout of the MovieEditor window. In some cases, however, they are very important; for example, when used with RadioButtons. Figure 7 shows what the finished layout should look like. This concludes the layout for the MovieEditor window, so go ahead and close it now.


Figure 7.The completed MovieEditor window.

The second window involved in the Movie Editor application is the EditClip window. This window, when finished, will allow a user to edit the individual settings of a particular clip from the MovieEditor window. Drag three EditField controls to the EditClip window and name them "ClipName", "ClipStart", and "ClipEnd". Add two LittleArrows controls to the window, positioning one next to the ClipStart EditField and the other aside the ClipEnd EditField. For now, leave them with the default names of "LittleArrows1" and "LittleArrows2".

Next, drag two buttons to the EditClip window and name them "SaveButton" and "CancelButton". Also, be sure to check the Caption properties of the buttons to reflect the correct function of the button. Finally, add a Checkbox control entitled "PreviewCheckbox" and a StaticText control named "TotalTime". To finish off the appearance of the window, label each of the control using StaticText controls. Figure 8 displays the completed EditClip window.


Figure 8.The completed EditClip window.

The final window added to the project is called "About". It will contain a display picture about the MovieEditor application. To add this graphic to your project, simply drag it into the project window from the Finder, or add it using the appropriate menu from the File menu. Once it has been added to the project, you can make it display in the background of your About window by changing the Backdrop property of the About window.

In addition to the windows that appear in your application, you will need menus. After all, what's a Macintosh program without menus? To add menus to your program, open the Menu Editor from the Project window. Select the File menu item in the Menu Editor. The menu will expand and you will be able to add a menuitem at the bottom of the list. Change the properties of the MenuItem in the Property Window just as you have for all other properties. For this application, add an "Open" MenuItem. Set the CommandKey property to a capital letter "O". This adds the Cmd-O keyboard shortcut found in most Macintosh programs. To move the "Open" menu item to the top of the File menu simply drag it into place. To finish the menus for this project add an "About Movie Editor..." menu under the Apple Menu.

This concludes the interface-building phase of the MovieEditor project. Feel free to experiment with the layout of your interface. This will give you a chance to see how things work in REALbasic.

The Source Code

The next step in constructing the application is to add source code. Before you start typing, though, it is a good idea to add necessary properties to each window. These user-defined variables are within the scope of the parent window. All parts of the window can access the properties directly. To add a new property, select Edit:New Property. The properties for the MovieEditor window appear in Figure 9.


Figure 9.The MovieEditor properties.

The EditClip window also requires two properties. Add them by first opening the Code Editor for the EditClip window. Add the properties as you did for the MovieEditor window. Figure 10 lists the properties.


Figure 10.The EditClip properties.

In addition to menus, our application will make use of a class. The class we will add is the Application class. This class supersedes everything else in the application hierarchy. Within the application class is where we will enable menu items and put code to tell our application where to proceed when a menu item is selected. For all of you C programmers out there, you might make an analogy to the main event loop typical in standard Macintosh programming. Don't take this analogy too far, however, because you can also alter and handle menu items elsewhere in your REALbasic project.

To add an Application class to your project, select File:New Class from the File menu. A new class will appear with its code editor opened. Change the name property to "App" and the Super property to "Application". Next, expand the Events hierarchical list to reveal its contents. Select the Enable Menu Items item within the hierarchy. In the area to the right of the Code Editor window is where our code will go. Add the code from Listing 1.

Listing 1. The App.EnableMenuItems event.

	FileOpen.enabled = true //enable the Open menu item
	AppleAboutMovieEditor.enabled = true //enable the About menu item

The code sets the enabled property of the two menu items to true. Now your menus will not be dimmed. You may have also noticed that comments were added to the code in a fashion similar to C++. Anything following the double slash will be ignored by the compiler for that line only. To maintain compatibility with VisualBasic a single quotation mark character can also be used to denote a comment.

Once the menus are visible, they have to do something when selected. To respond to menu selections, you must add a MenuHandler to the Application class. Select "Edit:New MenuHandler". In the window, that appears select "AppleAboutMovieEditor" and select "OK". A MenuHandler will be added to the Application class Code Editor. Enter the following code.

Listing 2. The AppleAboutMovieEditor MenuHandler.

	About.show //show the About window

When a user selects the About menu, the About window we created earlier will be displayed. Similarly, the MovieEditor is called by a MenuHandler, but the code is a bit more involved. Add a MenuHandler to the application for the FileOpen menu item. To this handler add the code in Listing 3.

Listing 3. The FileOpen MenuHandler.

	dim f as folderItem
	dim w as MovieEditor
	
	//display the Open file dialog box and allow the user
	//to choose QuickTime movies only
	
	f=getopenFolderItem("video/quicktime")
	
	if f <> nil then //as long as the user chooses a file
		w=new MovieEditor //open a new movie editor window
		//load the movie from the file they chose into the movie player
		w.movieplayer1.movie=f.OpenAsMovie
	end if

In listing 3 we first creates two variables f, and w. The variable f is of the type FolderItem. A FolderItem is a reference to a file. This will be the movie file the user wishes to open. The w variable is of the type MovieEditor. Remember that windows in REALbasic are actually classes. Just as in other object-oriented languages, REALbasic allows you to create objects based on classes. The class you made is a template for the creation of a window object.

The next line of code prompts the user for a QuickTime file. The file type enclosed within the quote marks is defined under the Edit:FileTypes menu. Create a new file type as shown in Figure 11.


Figure 11.Add a QuickTime file type in the File Type Editor.

Your project can now properly look for QuickTime files. If a user decides not to open a file and clicks the Cancel button, REALbasic expects to know about it. Therefore, you will note that once the call to GetOpenFolderItem is made, the remainder of the code is enclosed within an if-statement. If no file was selected, then the code has somewhere to go - the end of the subroutine. Without this code, REALbasic will present you with an error. If a file was selected, a new MovieEditor window object is created with the name of w. Furthermore, the Movie property of the MoviePlayer in the w object is set to the file f. As soon as the window is created, a movie file has been assigned to its MoviePlayer control.

The final step before finishing the Application class is to change the project settings. Open the Edit:Project Settings... menu. A window appears where you can assign the Default Window, the Creator Code of the application, and the language. Set the Default Window setting to "<none>" and click OK. Since no window is set to default, your Application class will be responsible for getting the ball rolling through the MenuHandlers. Figure 12. gives a pictorial representation of the layout of the application. The App class calls the About window or the MovieEditor window through the MenuHandlers. The EditClip window is in turn created by the MovieEditor window.


Figure 12.The layout of the application.

With the application core being setup the next step is to add code to each of the individual windows. We begin with the About window. Open the About window editor and double click again to open the Code Editor. In the MouseDown event enter the command Close. When a user click somewhere in the window, it will close. Close the Code Editor and the About window.

Open the MovieEditor Code Editor. Select the menu Edit:New Method.... This allows you to create a new method in the window. A method in REALbasic is identical to a function in C. It can accept and return values. For this example, create a new method with the name "SwitchRows". Give it parameters as shown in Figure 13.


Figure 13.Defining the SwitchRows method.

Listing 4 details the code for the SwitchRows method. You need not enter the first two lines of code. Those have been done for you. Thus, begin on the line after the line that begins with "Sub". You can also ignore the "End Sub" line of code when entering the source. The remainder of the code for the MovieEditor window follows the SwitchRows method. It is broken up by subroutine. The code is fully commented, so I won't go into the details here. The specifics of particular commands can be referenced by selecting the Window:Reference menu in the REALbasic IDE or within the documentation provided by REALsoftware. See the Reference section for details. Now, on to the code.

	MovieEditor.SwitchRows:
	Sub SwitchRows(row1 as integer, row2 as integer)
		//This method switches the data in the two rows passed
		dim i as integer //the loop counter for the For loop
dim Values(0) as string //temporarily holds the values from one row
//resize the values array to the number of columns in the list
		redim values(ClipList.columncount-1) 
 
		//go through each row and copy the values from row 1 into 
		//the values array then copy the values in row 2 into row 1
		//lastly, copy the values from the values array into row2
		for i = 0 to ClipList.columncount - 1
			//save the values in the row1
			values(i) = ClipList.cell(row1, i)
			//now move the values in row2 into row1
			ClipList.cell(row1, i) = ClipList.cell(row2, i)
			//now move the values from row1 (saved) into row2
			ClipList.cell(row2, i) = values(i)
		next
 
		//move the selection to row2
		ClipList.listindex = row2
	End Sub

	MovieEditor.ClipList.DoubleClick:
	Sub DoubleClick()
		// Open a new EditClip window and copy data from the listbox
		//into it for editing
 
		//store a reference to the Movie Editor window that the user
		//double-clicked on
		editClip.SourceWindow=self
 
		//Store the number of the row in the listbox the user
		//double-clicked on
		editClip.RowEdited = ClipList.listindex
 
		//Set the title of the new window to the name of the clip
		//from the listbox
		editClip.title = ClipList.cell(ClipList.listindex,0)
 
		//Set the name field to the name of the clip
		editClip.ClipName.text = editClip.title
 
		//Set the start field to the start time from the listbox
	editClip.ClipStart.text = ClipList.cell(ClipList.listindex, 1)
 
		//Set the end time field to the end time from the listbox
		editClip.ClipEnd.text = ClipList.cell(ClipList.listindex, 2)
 
		//Set the total time field to the total time from the listbox
	editClip.TotalTime.text = ClipList.cell(ClipList.listindex, 3)
	End Sub

	MovieEditor.ClipList.Change:
	Sub Change()
		if me.listindex<0 then // if no rows are highlighted
  
			//disable the Play, Up and Down buttons
			playButton.enabled=false
			UpButton.enabled=false
			DownButton.enabled=false
  
		else //at least one row is selected so enable the Play button
  
			playButton.enabled=true
  
			if me.listindex=0 then //if the first row is selected
				upButton.enabled=false //disable the up button
				else //the first row isn't selected
				upButton.enabled=true //so disable the Up button
			end if
  
if me.listindex=me.listcount-1 then //if the last row is selected
				DownButton.enabled=false //disable the Down button
			else //the last row isn't selected
			DownButton.enabled=True //so enable the Down button
			end if
		end if
 
	End Sub

	MovieEditor.RecordButton.Action:
	Sub Action()
		dim row as integer
		dim start, stop as double
 
if me.caption="Record" then //if this button is labeled "record"
  
			//add a new row to the listbox
			ClipList.addrow "Clip "+str(ClipList.listcount)
  
			//fill in the start time with the current position of the movie player
	ClipList.cell(ClipList.listcount-1,1)=str(moviePlayer1.position)
  
			//start playing the movie
			moviePlayer1.play
  
			//Re-label this button to "Stop"
			me.caption="Stop"
  
else //the user clicked the button while it was labeled "Stop"

			//stop the movie player
			moviePlayer1.stop
  
			//determine which row is selected
			row=ClipList.listcount-1
  
			//get the stop time and record it in the list
			ClipList.cell(row,2)=str(moviePlayer1.position)
  
			//calc the total time for the segment
			start=val(ClipList.cell(row,1))
			stop=val(ClipList.cell(row,2))
  
			//record the total time in the list
			ClipList.cell(row,3)=str(stop-start)
  
			//Set the button's label back to "Record"
			me.caption="Record"
		end if
	End Sub

	MovieEditor.PlayButton.Action:
	Sub Action()
		dim i as integer
		//Clear the list of clips to play
		redim clipsToPlay(0)
 
		//make a list of the clips to be played
		//and store the row numbers in the ClipsToPlay array
		for i=0 to ClipList.listcount-1 //for each row in the list
			if ClipList.selected(i) then
				//add a new row to the array
				redim clipsToPlay(ubound(clipsToPlay)+1)
				//store the row number in the array
				clipsToPlay(ubound(clipsToPlay))=i
			end if
		next
 
		//Reset the clip playing tracker
		clipPlaying=1
 		//set the position of the movie player to the begining of the first clip

moviePlayer1.position=val(ClipList.cell(clipsToPlay(clipPlaying),1))
		//start playing the movie
		moviePlayer1.play
 
		//Turn on the timer control
		timer1.mode=2
 
		//Disable the play button
		me.enabled=false
	End Sub

	MovieEditor.MoviePlayer1.DropObject:
	Sub DropObject(obj As DragItem)
		//remove all existing rows from the listbox
		//because they are for the last movie edited
		ClipList.deleteAllRows
		//Assign the move dropped to the movie player
		Movieplayer1.movie=obj.folderitem.OpenAsMovie
	End Sub

	MovieEditor.MoviePlayer1.Stop:
	Sub Stop()
		 dim i as integer
		//Check to see if any rows in the clip list are selected
		//and if any are, enable the Play button
		for i = 0 to ClipList.listcount-1
		if ClipList.selected(i) then
			playButton.enabled=true
			exit
		end if
		next
 
	End Sub

	MovieEditor.MoviePlayer1.ControllerSizeChanged:
	Sub ControllerSizeChanged()
		//if the movie is too tall, resize the window to fit
		//if (me.top+me.ControllerHeight) > (self.height-13) then
		self.height=me.top+me.ControllerHeight+13
		//end if
 
		//if the movie is wider than the window
		if (me.Left+me.ControllerWidth) > (self.Width-13) then
			//make the window wide enough for the movie
			self.Width=me.Left+me.ControllerWidth+13
		//if the movie is wider than the minimum width of the window
			elseif (me.Left+me.ControllerWidth) > self.MinWidth then
			//set the width of the window to the width of the movie
				self.Width=me.Left+me.ControllerWidth+13
else		//the movie must be narrower than the minimum window width
			//size the window to its minium width
			self.Width=self.MinWidth
			end if
	End Sub

	MovieEditor.MoviePlayer1.Open:
	Sub Open()
		//allow quicktime movies to be dropped on the movie player
		me.acceptfileDrop("video/quicktime")
	End Sub

	MovieEditor.Timer1.Action:
	Sub Action()
		dim i as integer
 
		//Determine if the movie player is going beyond the 
		//end of the current clip
if moviePlayer1.position> = val(ClipList.cell(clipsToPlay(clipPlaying),2)) then
  
			//it's time to switch to the next segment
			//so increment the counter that tracks which clip is playing
			clipPlaying = clipPlaying + 1
  
			//If there's another segment to be played
				if clipPlaying <= ubound(clipsToPlay) then 
   
				//reset the position of the movie player to the
				//start time of the next clip

moviePlayer1.position=val(ClipList.cell(clipsToPlay(clipPlaying),1))
				else //there are no more clips to play
				moviePlayer1.stop //stop the movie
clipPlaying=0 //reset the ClipPlaying tracker to zero
redim clipsToPlay(0) //clear the list of clips to play
me.mode=0 //turn off the timer so it doesn't keep executing this code
				end if
		end if
	End Sub

	MovieEditor.UpButton.Action:
	Sub Action()
		//Call the window's SwitchRows method
		//and pass it the selected row from the list and the row
		//above the selected row
		SwitchRows(ClipList.listindex, ClipList.listindex - 1)
	End Sub

	MovieEditor.DownButton.Action:
	Sub Action()
		//Call the window's SwitchRows method
		//and pass it the selected row from the list and the row
		//below the selected row
		SwitchRows(ClipList.listindex, ClipList.listindex + 1)
	End Sub

Once the code has been entered, close the MovieEditor Code Editor and open the EditClip Code Editor. Create two new methods. The first method is called "PreviewFrame" and has "Position as Double" as a parameter and no return value. The second method to create is "ReadyToSave" and has no parameters and no return value. Listing 5 details the code to enter into the various parts of the EditClip window.

Listing 5. EditClip source code.

	EditClip.ReadyToSave:
	Sub ReadyToSave()
		if val(ClipStart.text) < val(ClipEnd.text) then
			SaveButton.enabled = true
		else
			SaveButton.enabled = False
		end if
	End Sub
	EditClip.PreviewFrame:
	Sub PreviewFrame(Position as Double)
		If PreviewCheckbox.value then
		sourceWindow.moviePlayer1.position = Position
		end if
	End Sub
	EditClip.ClipStart.GotFocus:
	Sub GotFocus()
		PreviewFrame(val(me.text)) //show the first frame of the clip
	End Sub
	EditClip.ClipStart.TextChange:
	Sub TextChange()
		ReadyToSave //see if the Save button should be enabled recalculate the total time
	totalTime.text = str( val(ClipEnd.text) - val(ClipStart.text) )
		//Reset the movie to the start position
		PreviewFrame(val(me.text))
	End Sub
	EditClip.ClipEnd.GotFocus:
	Sub GotFocus()
		PreviewFrame(val(me.text)) //show the last frame of the clip
	End Sub
	EditClip.ClipEnd.TextChange:
	Sub TextChange()
		ReadyToSave //determine if the Save button should be enabled
		//recalculate the total time
	totalTime.text = str( val(ClipEnd.text) - val(ClipStart.text) )
		PreviewFrame(val(me.text)) //show the last frame of the clip
	End Sub
	EditClip.SaveButton.Action:
	Sub Action()
		//Put the edited clip name, start, stop and total times back
		// in the select row of the listbox in the movie editor window
		SourceWindow.ClipList.cell(RowEdited,0) = ClipName.text
		SourceWindow.ClipList.cell(RowEdited, 1) = ClipStart.text
		SourceWindow.ClipList.cell(RowEdited, 2) = ClipEnd.text
		SourceWindow.ClipList.cell(RowEdited, 3) = totalTime.text
		Close
	End Sub
	EditClip.CancelButton.Action:
	Sub Action()
		Close
	End Sub
	EditClip.ClipName.TextChange:
	Sub TextChange()
		//Call the ReadyToSave method of this window
		//and see if the Save button should be enabled
		ReadyToSave 
title = me.text //set the window title to the name of the clip
	End Sub
	EditClip.LittleArrows1.Up:
	Sub Up()
		//increment the start time by .1
		ClipStart.text = str( val(ClipStart.text) + .1 )
	End Sub
	EditClip.LittleArrows1.Down:
	Sub Down()
		//decrement the start time by .1
		ClipStart.text = str( val(ClipStart.text) - .1 )
	End Sub
	EditClip.LittleArrows2.Up:
	Sub Up()
		////increment the end time by .1
		ClipEnd.text = str( val(ClipEnd.text) + .1 )
	End Sub
	EditClip.LittleArrows2.Down:
	Sub Down()
		//decrement the end time by .1
		ClipEnd.text = str( val(ClipEnd.text) - .1 )
	End Sub

Once all of the code has been entered, it is time to test the application. Select the Debug:Run menu. Your application should launch. Select File:Open and open a QuickTime movie. You can now create clips by pressing the "Record" button. Record until you wish to end the clip. Record a few more clips. Select one of the clips in the middle of the clip list and press the "Up" button. Your clip should move up in the clip order. When you press the "Play" button, the clips will be replayed in the order you arranged. If you run into any problems trying to get your project to run, recheck your code. Is it all entered correctly? Have all windows, menus, properties, and methods been added to your application. Have you added a QuickTime file type? Have you set the Project Settings default window to "<none>"? If there is a problem in the code, REALbasic should point out where for you upon debugging. Again, the documentation from REALsoftware provides more information about debugging in REALbasic. Once you are finished testing the project, select the "Quit" menu and return to the REALbasic IDE. The completed application should look like Figure 14.


Figure 14.The completed MovieEditor application.

Once you have built the interface, it is time to build the final application. Select the menu File:Build Application and make the settings similar to Figure 15.


Figure 15.The final build settings.

You may want to customize your application by pasting an icon into the final build settings. Other than that, you have just built a complete movie clip editing application in a fraction of the time it would take using traditional means. Well, ok, it isn't complete, but it is functional. If I included the complete source, you would not have any reason to expand your horizons by adding functionality to the application yourself. Furthermore, you should take this time to check the Reference section for example code. There is a large community of REALbasic users on the web and they are often very willing to answer your REALbasic questions. I highly recommend becoming a member of the electronic mailing lists. Here you can ask fellow REALbasic programmers questions as well as follows threads about questions other programmers have.

Conclusion

In this article, we looked at the various features of REALbasic 2, had a brief tour of the IDE, and built a movie editor application complete with working menus, windows, and QuickTime functionality. To accomplish the same feat in C/C++ would require countless lines of code, particularly in the Toolbox department. REALbasic takes away the hassle of recoding the interface and lets you get down to the task at hand - coding. Granted, REALbasic is not intended for all types of Macintosh development like shared libraries or code resources, but for many types of applications, it is the clear choice for discriminating Mac developers.

Bibliography

The best information available to the new REALbasic programmer is the Internet. A good place to begin is the REALbasic home site. There you can download the REALbasic application, documentation, tutorials, sample code, and examples. You can also find instructions for subscribing to the various email lists available to REALbasic programmers.

Other sites have source code, example projects, plugins, and tips available for download. Many of the plugin authors are also the same people on the listservs who will be willing to answer questions you might have regarding plugins.

A new book has also been published by O'Reilly and Associates entitled REALbasic-The Definitive Guide. It is by Matt Neuberg and covers REALbasic in depth. You can find out about it at his site.

An excellent site for tutorials and tips for REALbasic programmers. Every topic is covered here with loads of examples.

The REALbasic Web Ring is a listing of dozens of REALbasic related sites. Set up your own site today and become a Ring member!


Erick J. Tejkowski is an IT professional for the Macintosh-loving Zipatoni Company in St. Louis, Missouri. When he's not busy trying to raise his daughter with his wife Lisa, he programs shareware and freeware software for his own Purple E Software. His software has appeared in Macintosh publications around the world. You can reach him at ejt@norcom2000.com.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

BBEdit 11.1.1 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
CrossOver 14.1.3 - Run Windows apps on y...
CrossOver can get your Windows productivity applications and PC games up and running on your Mac quickly and easily. CrossOver runs the Windows software that you need on Mac at home, in the office,... Read more
Little Snitch 3.5.3 - Alerts you about o...
Little Snitch gives you control over your private outgoing data. Track background activity As soon as your computer connects to the Internet, applications often have permission to send any... Read more
OmniGraffle Pro 6.2.3 - Create diagrams,...
OmniGraffle Pro helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use... Read more
OmniFocus 2.2 - GTD task manager with iO...
OmniFocus helps you manage your tasks the way that you want, freeing you to focus your attention on the things that matter to you most. Capturing tasks and ideas is always a keyboard shortcut away in... Read more
Cocktail 8.4 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
PDFKey Pro 4.3 - Edit and print password...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Kodi 15.0.beta1 - Powerful media center...
Kodi (was XBMC) is an award-winning free and open-source (GPL) software media player and entertainment hub that can be installed on Linux, OS X, Windows, iOS, and Android, featuring a 10-foot user... Read more
DiskCatalogMaker 6.4.12 - Catalog your d...
DiskCatalogMaker is a simple disk management tool which catalogs disks. Simple, light-weight, and fast. Finder-like intuitive look and feel. Super-fast search algorithm. Can compress catalog data... Read more
Macs Fan Control 1.3.0.0 - Monitor and c...
Macs Fan Control allows you to monitor and control almost any aspect of your computer's fans, with support for controlling fan speed, temperature sensors pane, menu-bar icon, and autostart with... Read more

Moleskine Timepage – Calendar for iCloud...
Moleskine Timepage – Calendar for iCloud, Google & Exchange 1.0 Device: iOS iPhone Category: Productivity Price: $4.99, Version: 1.0 (iTunes) Description: The most elegant calendar for your pocket and wrist, Timepage is a... | Read more »
QuizUp Gets Social in its New Update
Plain Vanilla Corp has released a new and improved version of their popular trivia game, QuizUp. The app now emphasizes social play so you can challenge friends from all over the world. [Read more] | Read more »
The Deep (Games)
The Deep 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Swipe Controls Delve into the deep in this retro rogue-like! Swipe to move your diver around and keep away from the enemies as you... | Read more »
Battle of Gods: Ascension (Games)
Battle of Gods: Ascension 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: TURN-BASED TACTICAL COMBATFight tactical battles against the forces of Hades! In Battle of Gods: Ascension you play... | Read more »
Shadowmatic's Latest Update Adds a...
Shadowmatic's shadowy shadow-ness is getting a little shadowy-er thanks to a recent update that adds an Arcade Mode. [Read more] | Read more »
Sunrise Calendar and Slack Have Assimila...
Wunderlist is perhaps one of the most populat and beloved productivity apps on the App Store - and now it's gone and incorporated itself into other useful services like Sunrise Calendar and Slack. [Read more] | Read more »
Crossy Road Devs Hipster Whale are Bring...
Hipster Whale, the minds behind the rather popular (and rather great) Crossy Road, have teamed-up with Bandai Namco to create PAC-MAN 256: an absolutely bonkers looking maze runner chaser thing. | Read more »
Meet the New Spotify Music
Spotify Music  has a lot going on. They're introducing 3 new modes to serve all your musical needs, with the "Now" start page  gives you curated playlists based on your particular tastes. As you listen the app will learn more about your tastes and... | Read more »
What the Apple Watch Gets Right, and Wha...
| Read more »
Celebrate PAC-MAN's 35th Birthday W...
BANDAI NAMCO Entertainment America is celebrating PAC-MAN's 35th anniversary by releasing updates for PAC-MAN and PAC-MAN Lite for iOS. [Read more] | Read more »

Price Scanner via MacPrices.net

Apple refurbished 2014 13-inch Retina MacBook...
The Apple Store has Apple Certified Refurbished 2014 13″ Retina MacBook Pros available for up to $400 off original MSRP, starting at $979. An Apple one-year warranty is included with each model, and... Read more
What Would the ideal Apple Productivity Platf...
For the past four years I’ve kept a foot in both the Mac and iPad camps respectively. my daily computing hours divided about 50/50 between the two devices with remarkable consistency. However, there’... Read more
PageMeUp 1.2.1 Ten Dollar Page Layout Applica...
Paris, France-based Softobe, an OS X software development company, has announced that their PageMeUp v. 1.2.1, is available on the Mac App Store for $9.99. The license can be installed on up to 5... Read more
Eight New Products For USB Type-C Application...
Fresco Logic, specialists in advanced connectivity technologies and ICs, has introduced two new product families targeting the Type-C connector recently introduced across a number of consumer... Read more
Scripps National Spelling Bee Launches Buzzwo...
Scripps National Spelling Bee fans can monitor the action at the 2015 Spelling Bee with the new Buzzworthy app for iOS, Android and Windows mobile devices. The free Buzzworthy app provides friendly... Read more
13-inch 2.5GHz MacBook Pro on sale for $120 o...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $979 including free shipping plus NY sales tax only. Their price is $120 off MSRP, and it’s the lowest price for this model (except for Apple’... Read more
27-inch 3.3GHz 5K iMac on sale for $1899, $10...
B&H Photo has the new 27″ 3.3GHz 5K iMac on sale for $1899.99 including free shipping plus NY tax only. Their price is $100 off MSRP. Read more
Save up to $50 on iPad Air 2, NY tax only, fr...
B&H Photo has iPad Air 2s on sale for up to $50 off MSRP including free shipping plus NY sales tax only: - 16GB iPad Air 2 WiFi: $469 $30 off - 64GB iPad Air 2 WiFi: $549.99 $50 off - 128GB iPad... Read more
Updated Mac Price Trackers
We’ve updated our Mac Price Trackers with the latest information on prices, bundles, and availability on systems from Apple’s authorized internet/catalog resellers: - 15″ MacBook Pros - 13″ MacBook... Read more
New 13-inch 2.9GHz Retina MacBook Pro on sale...
B&H Photo has the 13″ 2.9GHz/512GB Retina MacBook Pro on sale for $1699.99 including free shipping plus NY tax only. Their price is $100 off MSRP, and it’s the lowest price for this model from... Read more

Jobs Board

*Apple* Solutions Consultant - Retail Sales...
**Job Summary** As an Apple Solutions Consultant (ASC) you are the link between our customers and our products. Your role is to drive the Apple business in a retail Read more
*Apple* Watch SW Application Project Manager...
**Job Summary** The Apple Watch software team is looking for an Application Engineering Project Manager to work on new projects for Apple . The successful candidate Read more
Engineering Manager for *Apple* Maps on the...
…the Maps App Team get to take part in just about any new feature in Apple Maps, often contributing a majority of the feature work. In our day-to-day engineering work, we Read more
Senior Software Engineer - *Apple* SIM - Ap...
Changing the world is all in a day039s work at Apple . If you love innovation, here039s your chance to make a career of it. You039ll work hard. But the job comes with Read more
Lead *Apple* Solutions Consultant - Retail...
**Job Summary** Job Summary The Lead ASC is an Apple employee who serves as the Apple business manager and influencer in a hyper-business critical Reseller's store Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.