Leopard Programming
| | Like most people, you've probably thought that the skills that are required to build your own computer software are so advanced that you could never hope to become a programmer by trade or by hobby, but I'm here to tell you that it doesn't have to be that way. Sure, many modern programming languages are all about complexity, but there are ways to get started without having to break a mental sweat. When I first started programming, I was frustrated with the lack of tools for beginning programmers like myself, and this drove me to create the beginner's language that I never found once I polished my skills and gained more knowledge about programming. The result of my work is a programming language called Leopard, and it's been used by everyone from students to advanced programmers. I've always wanted the language to have a strong educational presence, and that's why I teamed up with WeatherBug to distribute the tool through their WeatherBug Achieve network of schools. In addition to practical usage scenarios in the classroom, this implementation of the abundance of live weather data that WeatherBug provides into a programming language makes it easy for anyone to create their own weather application. Of course, Leopard is a standard programming language, so you can create whatever you want with the included functions, and you're certainly not limited to using weather data. To give you an example of how quick and easy it is to create a program in Leopard, let's create an application that makes use of some WeatherBug data. Since summer is almost upon us and many of us are thinking about how nice it would be to relax on the beach right about now, I'll show you how to create a simple weather application that details what the conditions are like in Panama City. |
| Brandon Watts Difficulty: Easy Time Required: Less than 1 hour Cost: Free Software: Leopard v2.1 Hardware: |
Creating a Window
To get started, the first thing that you need to do is specify the type of window that you want to use, which for this example is a regular window:
Now you enter the text that you want to appear in the title bar of the window:
The only thing that's left to do is customize the size of the window:
The first number is the width of the window, and the second number is the height. These numbers are declared in pixels.
That's all there is to it! You now have a basic window template to work from. Before showing you how to conclude and execute your program, let's first add all of the other components to our project.
Adding Controls
I want to add a live image of the beach to my program so that I can actually see what the current conditions are like, and thanks to WeatherBug's network of weather cameras, this isn't a problem:
The “PSMCT” reference is the name of the camera that I want to use, and you can find these camera names on the images from the WeatherBug InstaCam Web site (
http://www.instacam.com). The two numbers represent the x and y coordinates where the image is to be placed on the window.
Now that the camera image is a part of my window, I also want to add a button:
SE Radar is the text that I want to appear on the button. The first two numbers stand for the x and y coordinates of the button, and the last two numbers represent the width and height of the button itself.
To complete the look of the window, I also want to add a WeatherBug control which will tell us what the current temperature and wind speed and direction is:
32403 is the zip code that I want to retrieve the weather data for, and 180x150 is one of the predetermined sizes that I can use for this control. The final two numbers relate to the x and y coordinates of its location on the window.
Creating an Onclick Event
Since we've added a button to our window, we need to specify what that button does when it's clicked, and this is done by using an onclick event. Let's use this one:
That onclick command is now associated with the name of the control that's referenced (in this case, button), and it'll open up a WeatherBug radar map for us to examine. The title of the window that displays the map will be SE Radar, and the SE part of the code tells Leopard that we want to open the radar map for the southeast in order to see if there's any precipitation headed towards Panama City.
Playing Audio Before we finish working on our project, let's add a fun extra feature to the program that'll help you feel like you're close to the beach even if you aren't. I found an MP3 file that contained ocean sounds, and in order to make it play when the program is first opened, use this code:
Of course, you'll have to have a file called “ocean.mp3” in your Leopard directory in order for this to work.
Wrapping Things Up
The only thing that's left to do in terms of putting the finishing touches on the program is to issue the end command, which needs to be placed at the end of every Leopard program:
Piece of cake, right? Included below is the entire program from start to finish with some comments thrown in to help you make sense of what's going on. Anything that's not a command or part of a command set is treated like a comment by Leopard.
: Let's create our window. :
1: window
2:
3: window title
4: Sunburn Central
5:
6: window size
7: 563
8: 295
9:
10: weatherbug camera
11: PSMCT
12: 10
13: 10
14:
15: button
16: SE Radar
17: 350
18: 10
19: 183
20: 50
21:
22: weatherbug
23: 32403
24: 180x150
25: 350
26: 95
27:
28: button onclick
29: weatherbug radar
30: SE Radar
31: SE
32:
33: play mp3
34: ocean.mp3
35:
36: end
If you're interested, you can download a zip file that contains the complete program file as well as the MP3 file from here and then extract the contents of this file to your Leopard directory.
Conclusion
As you can see, programming in Leopard is unbelievably easy, and we've just scratched the surface of what you can do with the language! Please feel free to experiment with Leopard and send us your work so that we can share it with your fellow programmers. Programming doesn't have to be hard, but it can be fun, thanks to Leopard!
Brandon Watts
brandonwatts@gmail.com