Novell is now a part of Micro Focus

Developing for Multiple Platforms using Revolution

Novell Cool Solutions: Feature
By Richard Smith

Digg This - Slashdot This

Posted: 18 May 2005

Richard Smith
Developer Content Manager
Novell, Inc


If you frequent Cool Solutions for Developers you are very aware of the fact that we are always looking for tools to help you be more productive as a developer. These tools come in many forms and provide a variety of functionality depending upon the task they are designed to do. Another thing we look for is tools that will help you either migrate existing applications from another platform to SUSE Linux or increase your efficiency by highlighting tools that allow you to build applications that will run on multiple platforms from the same basic code base.

Special Offer for Cool Solutions Readers: Free Copy of Runtime Revolution

The good folks at Runtime Revolution have extended a special offer to Cool Solutions readers. They are offering it for free to Novell customers who know the secret code. See this page for details.

The tool we will be looking at in this article is Revolution from Runtime Revolution. Last month I gave a short overview of Revolution, where I basically described what Revolution is and where it fits. This month we'll actually look at creating a simple GUI application using Revolution on SUSE Linux 9.3 and then taking that exact same project and building it on Windows with no changes. You will also find an excellent series of articles here on Cool Solutions beginning with HowTo: Use a Runtime Revolution Window interface with the Linux Shell -- Part 1.

The article you are reading is designed to give you a quick idea of what can be done very quickly and easily with Revolution to create multi-platform applications. You can then delve deeper into Revolution using the series of articles mentioned above and the many resources provided on Runtime Revolution's Web site and within the product itself.

Let's get started...

For this example we are going to build a very simple desktop application that will hold a list of web site URL's and allow us to select them and launch the default configured web browser to take us immediately to the selected web page. Okay, nothing fancy, but it beats 'Hello World'!

After you get Revolution downloaded, installed and started you'll see the following screen:

From this screen you can begin to build your application. You will also note the revOnline Viewer. This is one of the very useful aspects of Revolution that can be used to get you productive quickly using the product. The Learning Center is especially helpful, and it is where I went to get started using Revolution. After you select the learning Center you will have the option of selecting either Video Tutorials or Sample Work. Both will provide a wealth of information regarding Revolution development. Using these tools I was able to build the application presented below in a very short time and get it running on Windows as well as SUSE Linux where it was developed.

You will notice that the screen shots presented here will be a mixture of Linux and Windows development shots. After building and testing the application on Linux, I moved the code to Windows and did the same there. Since everything worked the same, I decided to also build the application on Windows to determine how similar the development environments were between the two platforms. Everything worked the same on both for this example, thus a mixture of screen shots to illustrate the development.

Working on the Stack

Once you select to build a new stack you get a blank slate to work with and the first task is to use the tool palette to place components on this palette to form the interface you want to provide for users of your finished program. This screen shot illustrates the new stack with the two buttons placed on it, but no further customizing has occurred.

In order to customize the properties of a component you must right click on it and you will see this dropdown menu allowing you to either change the properties of the component or add/edit the script that is attached to a variety of events that can occur on a given component.

This next screen shot shows the Property Inspector of the List Box we will add to hold the list of URL's for our launcher.

The Property Inspector allows you to change a great number of attributes of a given component to make it do exactly what you need and make it look the way you want. You can continue to add components to the stack until you have the basic interface you want your application to have and then you can edit each to give it the look and feel you want.

Below is a shot of the application with the components added and edited to fit this application. Properties edited include the application title and the captions on each of the buttons. The Property Inspector has also been used to add an initial list of URL's to the List Box to allow for testing of the application's launch ability as soon as the pieces are all tied together. You will also notice that Auto highlight is chosen along with turning off text wrap in the list box.

The scripting capabilities of Revolution can be as complex or as simple as you want to make them, depending upon your goals. For this example the scripts attached to the buttons and to the list box for selecting the URL to launch are very basic.

This script is added to the mouse down event on the list box to select the URL on the selected line and place it in the text box control below it.

on mouseDown
  select the clickLine
  put the selectedText into field "Thebox" 
end mouseDown

Now that we can get the URL we want selected and placed in the text box we need to attach script code to the Launch URL button to actually make something happen.

Because of the powerful functions built into Revolution this can be accomplished with just the following code:

on mouseUp
    revGoURL field "Thebox"
end mouseUp	

Now when the Launch button is depressed and released the program will take the URL in the text box and pass it to the default configured web browser and launch the browser to that page.

Now that the code has been attached to the needed components we can test our application by selecting the top left icon on the palette which runs the scripts and puts the application in an interactive mode for testing its execution. Here what that looks like:

You'll notice that a line of text in the list box is selected and that line has been placed in the launch text box. The application is basically running in a debug like mode at this point helping you locate any errors you might have made.

The final feature added to the application at this time is the Load List button which allows you to load a file that contains a list of URL's to populate the list box for use.

on mouseUp
  put URL "file:URLList.txt" into field "Lister"
end mouseUp

To simplify this example the file is hard coded, but you can see how easy it is to open a file and ready the contents directly into the appropriate component, the list box in this case.

Let's make it an application

Now that we've completed the coding and testing, it's time to actually build the applications so it can run as a standalone program. From the file menu you first need to select "Save as Standalone application?" This will allow you to customize the build and output options for your finished application. Below are screen shots of the configuration screen for Linux/Unix and Windows.

As you can see from these shots, you can build for multiple platforms on your development platform of choice.

Here are screen shots of the applications running on their targeted platforms.

While the applications have the same basic look and feel, they have also taken on the standard look and feel for the platform upon which they are running. Nothing worse than having a Linux application looking like a Windows application!

In conclusion

Products like Revolution aren't for everyone, but as a fit for the niche it is targeted at, it is a very solid, capable product. Often applications of this nature will be used as quick prototyping tool to allow a developer to illustrate the concepts behind a design in a very quick time. While Revolution could be used in this fashion it certainly would be a waste of a very fine product that is capable of so much more.

In this article we just scratched the surface of what you can do with Revolution. The tool comes with a very powerful set of built-in functionality and could be used for most desktop application development.

Additional Resources

Runtime Revolution

Cool Solutions Revolution articles

Fourth World's Revolution Embassy (excellent third party Revolution site)

Revolution Web Ring

Download the simple sample application

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates