----------------------------------------------------- Developing Custom Amiga Applications with Amiga Basic Copyright (c) 1986, by Rick Phillips ------------------------------------ What are "Custom Amiga Applications"? This question is certainly somewhat subjective. What I mean by "Custom Amiga Applications" is software that makes use of those features of the Amiga that are not common on other microcomputers. For example, a custom Amiga application would make use of the Amiga's pull-down menus instead of displaying a menu on the screen and asking the user to select an item by typing a number or letter. It would make use of the mouse, color, graphics and sound (including voice synthesis) capabilities of the Amiga when appropriate. Other features that are standard on the Amiga (and non-standard on most other microcomputers) include a RAM disk, multi-tasking and the Workbench user interface. Once again, custom Amiga applications would take advantage of these excellent features. I am irritated when I see a "new Amiga application" that was developed for the Amiga but looks like it was written for an IBM PC (an archaic microcomputer of some popularity). I bought an Amiga because of its many outstanding features. I expect Amiga software to utilize those features. I realize that a number of the available applications are "ports" from the IBM PC environment and until more "true" Amiga applications come along, we are probably lucky to get them. The point is this: When designing new applications for the Amiga, I think that its advanced features should be utilized to their fullest potential. I believe that new applications which don't follow this simple and obvious rule will not do well. In this article I would like to discuss some of the tools that are available from Amiga Basic that make it easy to design and write custom Amiga applications. Microsoft Corporation has developed versions of Basic for just about every major microcomputer, including the IBM PC and the Apple MacIntosh. Amiga Basic was developed by Microsoft Corporation and is the most advanced version of Basic that I have seen. In addition to a number of commands that take advantage of specific features of the Amiga, Microsoft also included features that improve the language from a general programming standpoint. At the end of this article, I have listed the Amiga Basic commands that I believe are vital to writing custom Amiga applications (or just good programming in general). I encourage you to take a close look at these commands before you begin writing programs in Amiga Basic. In the remainder of this article, I will present a few Amiga Basic commands that are both easy to use and essential for creating custom Amiga applications. They allow the use of custom pull-down menus. The MENU command is used to create custom pull-down menus. The syntax is as follows: MENU menu-id, item-id, state [,title-string] "menu-id" is an integer from 1 to 10 that refers to the menu bar selection. The menu bar is the list of menu items that appears at the top of the screen when you depress the right mouse button. "item-id" is an integer from 0 to 19 (0 to 16 when in text 60 mode) that refers to the menu item selection. Menu items are the lists of items that appear when you depress the right mouse button and move the cursor to touch a menu bar item. "state" is an integer from 0 to 2. A value of 0 will disable a menu or menu item, 1 will enable a menu or menu item, and 2 will enable a menu item and place a check mark by it. "title-string" is a title assigned to either a menu bar item or an item underneath one. Note that this parameter is optional. The MENU command is very easy to use. An example will demonstrate this: MENU 1,0,1,"Options" MENU 1,1,1,"Screen" MENU 1,2,1,"Printer" MENU 1,3,1,"Voice" MENU 1,4,1,"Colors" MENU 1,5,1,"Quit" This series of MENU commands would overlay the first Amiga Basic default menu bar selection with one called "Options". When you hold down the right mouse button (commonly called the menu button) you would see the new menu bar item in place of the default "Project" menu bar item. When you move the cursor to touch the new "Options" menu bar item (while holding down the right mouse button) a list of items would drop down. The items would be "Screen", "Printer", "Voice", "Colors" and "Quit". If this seems confusing, I suggest running Amiga Basic and trying a few MENU commands. The MENU command allows you to set up custom menus. The workings of the menus are then handled automatically. You don't have to worry about displaying the menus, moving the highlight from one item to another as the mouse moves or anything else related to the workings of the menus. The only remaining items that you do have to worry about are detecting when a menu item has been selected and, of course, performing whatever functions are appropriate (based on the item that was selected from the menu). Detecting when a menu item has been selected is best accomplished via the ON MENU command. The ON MENU command is an event trap (similar to ON ERROR or ON BREAK). The syntax for the ON MENU command is as follows: ON MENU GOSUB label "label" is the label of a subroutine to which control is passed whenever a menu item is selected. Once you have set up a subroutine for processing menu selections and issued an ON MENU statement to tell Amiga Basic about the subroutine, you need to issue a MENU ON statement to actually begin event trapping (detecting menu selections). Finally, there are two menu functions that need to be called when you enter the subroutine for processing menus. They are: MENU(0) and MENU(1) MENU(0) returns the menu bar item that was selected. MENU(1) returns the item under the menu bar that was selected. I have provided a sample program that demonstrates the use of custom menus. It can be examined and/or run by following this procedure: 1) Boot the Amiga normally using Kickstart and Workbench. 2) Run Amiga Basic from Amiga Extras (or anywhere else that you may have copied it) 3) Put JUMPDISK in the internal drive and load "j:programs/menudemo" (select open from the Project pull-down menu) 4) Look at and study the code in the List window. 5) When you are ready, run the demo (select run from the pull-down menu). The sample program has many comments and should clear away any clouds that may have formed while reading this article. In closing I must admit that I have barely touched on "Developing Custom Amiga Applications with Amiga Basic." I did, however, present my definition of "Custom Amiga Applications" (your definition may be different) and I went into some detail in explaining how to use custom pull-down menus from Amiga Basic. I encourage both the beginner and the experienced programmer to experiment with the new and improved Amiga Basic commands before writing programs. There is a lot of power and flexibility in this implementation of Basic and you can save yourself a lot of time and effort later by learning now what these new and/or improved commands can do. Most importantly, the advanced commands available in Amiga Basic will enable you to write programs that truly are "Custom Amiga Applications". APPENDIX A list of Amiga Basic commands that should be investigated before you begin writing programs. AREA AREAFILL BREAK CALL CIRCLE CLEAR COLLISION COLOR GET LIBRARY LINE LSET MENU MOUSE OBJECT ON PAINT PALETTE PATTERN PUT SADD SAY SCREEN SCROLL SHARED SLEEP SOUND STICK STRIG SUB TRANSLATE WAVE WHILE...WEND WINDOW If you are new to Basic programming, I suggest that you begin by sitting down with the manual and, starting from the beginning, proceed through the entire manual. It is reasonably well written and begins with a tutorial. If, on the other hand, you are an experienced Basic programmer but new to Amiga Basic, I suggest that you take a look at the commands I have listed above. Most of them you probably won't recognize and those that look familiar may perform different functions than older commands by the same name. END OF TEST