home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1992 September & October / rerun-1992-09-10-side-a.d64 / hotkey.txt < prev    next >
Text File  |  2022-09-20  |  4KB  |  28 lines

  1. Hotkey
  2. By Richard Penn
  3.  
  4. Imagine you're using a word processor and you find you need to make a calculation, so you click on an on-screen calculator, do the figuring, and resume working. Then the phone rings, and as you're talking, you click on a calendar to confirm an appointment.
  5.  
  6. If you think creating pop-up accessories such as these is possible only for an expert programmer using machine language, think again: You can easily create them in Basic with Hotkey.
  7.  
  8. The Good Stuff
  9.  
  10. To see Hotkey in action, load and run the demo program as you would any Basic program. The demo calculator uses the same keys as a pocket calculator, except to clear the display you press home.
  11.  
  12. The Hot Key Setup
  13.  
  14. The utility works by setting up the F1 key as a "hot key" within your Basic programs. Pressing F1 puts the Basic program on hold and executes the code for the pop-up desk accessory (such as my calculator). Pressing F1 again returns you to the main program as if you had never left. Think of it as a powerful Gosub key that jumps to a subroutine with its own screen, VIC-II chip and variables.
  15.  
  16. To use Hotkey, add line 60 of the demo to the beginning of your Basic program. Then you will need to add the two commands SYS 49752,LINE and SYS 49877 to your Basic program.The first enables Hotkey and points to the first line of the desk accessory subroutine (i.e., the line that pressing F1 jumps the program to). Place this command near the start of your program. The second command disables Hot-key. This is an optional command, to be used at your discretion. 
  17.  
  18. Programming Desk Accessories
  19.  
  20. From the top down, a Basic program with Hotkey desk accessories must be organized as follows: First comes the main application program, along with any subroutines, followed by the desk accessory code, written as a separate program. At the beginning of the main program is the line to load the Hotkey.ml file into memory (line 60 of the demo), followed by the command SYS 49752,LINE (as explained above). The main program should have access to the desk accessory code only through the hot key.
  21.  
  22. When F1 is pressed, all important information about the main program such as Basic pointers, variables, screen and color memory, and the VIC-II chip are saved. Then Basic jumps to the chosen subroutine and executes it. This subroutine has its own variables (2559 bytes stored at memory locations (50689-53247), which are cleared each time you press F1. The display, however, is not cleared, so pop-up tools can be printed over the current screen for a window effect. The only quirk is that the cursor is positioned one column to the right of the "home" corner.
  23.  
  24. No screen or sprite changes made by a subroutine called by Hotkey are permanent. The utility remembers where you were, and pressing F1 restores the original program. The only exception is the SID chip, which cannot be peeked, and therefore cannot be saved.If you want to have several desk accessories, include a menu at the beginning of the hot key subroutine so the user can choose the one they want.
  25.  
  26. When programming pop-up accessories, it's best to write them separately, and merge them with the main program once they're debugged. This is because only the main set of variables is available to the Basic editor. If you press run/stop while a hot key subroutine is running and then type print a, the value of a in the main program, and not the subroutine, will be returned.
  27.  
  28. Even if you don't want to program your own accessories, use the calculator from the demo in your own programs by including lines 50-90 and 1000-1390.New Look and FeelHotkey gives Basic a new look and feel. Never before could Basic programs be so user-friendly, nor did the programmer have so much power at his fingertips. The click-on accessory possibilities are limited only by your programming prowess and your imagination.