|
In the last Chapter we looked at the WeatherCalc program that had already been created, and how the CASLide could be used to run, debug, compile, make, and install an existing application on the Windows and PDA targets. In this Chapter we'll show you how to:
You'll need to have read the last chapter before reading this one, or you should have a basic familiarity with the CASLide. Program SpecificationBefore starting a program we should know what were trying to accomplish and we should weigh our design options and make some decisions regarding these options. Normally this might involve quite a bit of discussion with our targeted user group, but in this case the user group will be ourselves. We're going to use the Wind Chill and Heat Index formulas used by the WeatherCalc sample application. We'll see how to provide a simple user interface, and with our success, we'll progressively try to provide a more sophisticated user interface. As this is our first application we're experimenting with our design options.
So our final program specification is one where there will be a momentary splash screen at start up. From here the user will be able to enter weather information and get weather indexes based on this information. The user could alternatively ask for information about the program, by asking for an about box. We'll do all this and keep within the demo compiler limits. Not quite the user interface sophistication of Hal from the movie 2001. Although our PDA has a speaker which CASL can control, we'll find it is a bit limited for carrying on a pleasant conversation. Most Palm devices don't have a microphone for listening, ruling out a sophisticated 2-way conversation. So although we'll be using labels, textboxes, and buttons for "talking" and "listening", just the same in honor of the movie, we'll call our program, Hal2001 anyway. It sounds a lot better than "Hello World". New Project (CPJ)Start the CASLide. You create a new project by using the menu command File | New Project, or using the New Project toolbar button. When using the menu command be sure to keep the New/Open/Close operations for Projects separate from those same operations for Files. A Project is a collection of Files. We'll look at File commands in detail later. You can tell what toolbar buttons do by hovering the mouse cursor over a button and a tip note will display. If you don't see the File Toolbar, you can toggle its display by using the menu command View | File Toolbar. You'll first see an Open Dialog box. You'll want to navigate to a folder where you'll want to keep your source code. You can create a new folder at any time by using the new folder button at the top of the dialog box. (We're assuming we all know our way around Windows. If you don't, we suggest consulting a Windows help book). Once you're in a folder where you'd like to keep your project files, type a program name. According to our program spec, we're using the name, Hal2001. Click Open. The CASLide creates a new project (CPJ), and by default provides an empty main source code window (CSL), and an empty form window (CFF). These windows correspond to files that are now in your project. Both files have the same name as your project. The creation processCreate and Debug IterationsWe can now begin creating our first application! How shall we do it? It's always best to start any application very simply, and add features one by one, testing each before proceeding with the next. We'll use this approach here. Forms and Display ObjectsOk so what's a form? A form is a collection of display objects that will appear to the user when the program is running. On Windows this will appear in a window. On the PDA this will be the full screen display. Display objects are things like a frame, a button, a textbox, a menu item, or a selector list. CASL CodeWhen the user interacts with a display object, things are presumably supposed to happen. You as the programmer are in charge of making these things happen. You do this by attaching CASL code to the event function that is invoked (run) when the user interacts with a display object. This interaction could be a tap, or entering text with the keyboard or graffiti. CASL can also respond to system events like a period of time elapsing. Frame, and LabelThe simplest application is one that will only display information. The classic example is a "Hello World" application. Since it's Hal2001 we're programming, perhaps our program should display, "Hello pilgrim, how was your day?" (Hal can be a bit condescending). We mentioned we'd be doing a lot of debugging as we go along. Well we already have an empty form and code window. What will happen if we run our "program" now? Make sure the selected target platform is "Windows Release" or "Windows Debug". Click the Run toolbar button (or menu command Execute | Run). Our program runs. It displays an empty form, and does nothing. That is just what we should have expected. Close the program by clicking the "x" button in upper right hand corner (or using the control menu in upper left hand corner). The frame is the container object for all display objects. The frame is the parent, and the other objects are children. Every CASL program needs at least one frame (assuming it will be displaying anything). In the Project Window, double click on the form file. The form file will now be active in the Form Builder Window. Tip: In the last chapter we looked how to move borders and temporarily close the Build Window, if we'd like to make more room form the Form Builder. You can also change the default screen size settings with the menu command View | Project Settings. The default is 320x320, but for smaller display resolutions, 160x160 may suit you better. Double click on the Form. A frame properties dialog box will come up. The CASLide created a frame for your new project by default. At this point we suggest giving your frame a name, and the Display property contents will define the title bar of this form. Let's call the frame, frMain, and type this in the Name textbox. Let's type, Hal2001 in the Display textbox. Note, you don't put quotes around the text you enter into property textboxes. This is true when the Expression checkbox is left unchecked. You can enter a legal CASL string expression and click the Expression checkbox, if you'd like the content to be evaluated before assigning to the Display property. Click OK. Click Run. Your program should be running and "Hal2001" should be displayed on the title bar. Pretty good, eh? Ok, so we've got a bit more in mind for our application. Let's use a label object to display a bit more text. Select on the label button on the Form Controls toolbar. Then click the left mouse button at the desired location on the form. While holding the left button down, drag the display object to the desired shape. Tip: An existing display object can be selected, copied and then pasted to the same form or a different form. Delete all selected objects with the Del key.
|
[ Top ] © 2001, Feras Information Technology. All rights reserved. |