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

Latest Forum Discussions

See All

Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »

Price Scanner via MacPrices.net

Amazon is offering a $100 discount on every M...
Amazon is offering a $100 instant discount on each configuration of Apple’s new 13″ M3 MacBook Air, in Midnight, this weekend. These are the lowest prices currently available for new 13″ M3 MacBook... Read more
You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.