** 1 page regular /834 words ** Basic BASIC! ** On Reader disk logo here ** 10 pront "How to make an idiot happy for an hour" : goto 10 Paul Jones continues his series with a look at some useful features... EXECutions, yay or nay? An execution of a program is achieved by double-clicking on a program at the desktop. However, as you may already know, your HiSoft BASIC programs can also run other external programs when they themselves are being executed. A command line (remember those?) can also be sent to the program. This is very useful for PDO because instead of writing a dedicated display routine, the user can specify any editor to view the file instead. You'll find the execute source code on the Reader Disk. I suggest you use these in preference to the built-in execute/run subroutines of the basic library. This routine is "clean" - it hides the menu from view before starting the program, so GEM doesn't get confused and try to display two different menus at the same time! Much better execute routines can be found in the HGT's and ENCHANT. For the execution we use the GEMDOS command PEXEC. Check your HBASIC technical reference for more information about this command. The first thing it does is to change the current directory and drive to that of the program to be executed. This makes it possible for programs to find ancillary files, such as a resource file, in its own directory. If the current directory and drive was not changed, the executed program would look in the directory of the HBASIC program, and not find the file it requires (or maybe even the wrong file). The next thing is to ascertain the current top-most window (using wind_get WF_TOP) and the dimensions of the screen (using wind_get WFWORKXYWH) so the top window can be restored after the program is executed and the whole screen is redrawn. This method works well in a single-tasking environment but in a multi-tasking environment a better solution is needed: the AV protocol. AVing around The AV protocol was first developed for use with the GEMINI replacement desktop. The idea was to provide a way for individual applications to communicate with each other. Consider a MOD file player running as a desktop accessory with a different program file assigned to the MOD file extension. When double-clicking on a MOD file on the desktop, the program assigned to the MOD file extension is executed and sends the path to the desktop accessory which plays the MOD file! For experienced programmers I have created a series of disks called The HiSoft BASIC Useful Routines and Documentation Guide (THBURADG) which includes the MOD file player software and library. The disk can be ordered using the Reader Offers order form on page 10. We'll be concentrating on a simple example. The EXEC1 routine is ran as an accessory. Accessories work slightly differently to programs, as can be seen if you look at the source code. The same event_multi loop exists, but this time, the routine will receive an AC_OPEN if the user has selected it from the desk menu. The AV message can also be received, and will display the filename sent to it by the other routine when appropriate. The message is actually a number representing the function, where the following information is in the message space accordingly. The sending application must also comform to the protocol in order for the command to be successful. Sending is slightly more difficult. First you have to establish the GEM identification number of the program you wish to send too, this is done using the appl_find command then building up the message to be sent. The message is sent via the appl_write command - refer to GEM documentation for a more detailed description. As discussed in previous issues the VA protocol can be used for multi-tasking operations. Both elements can be incorporated into a single execute routine. In a multitasking environment we can perform a series of checks to determine which routine to use: ** UL ** * Is the system single or multi-tasking? * IF single-tasking, execute program : END * In a multi-tasking system, is the program to be executed already running? * IF NOT then execute with parameters * ELSE issue AV protocol ** /UL ** This series of steps can be turned into a program, check out EXEC3 on the Reader Disk. This routine could also be incorporated into PDO but since the next column will also be the last I'll concentrate on programming in general rather than further development of specific projects. Next time I'll let you know how you can keep in touch with HBASIC developers and offer some insights into Virtual Language. Email: paul.jones31@virgin.net http://vzone.virgin.net/paul.jones31/ ** boxout ** ** FIN.GIF here ** GEMDOS errors and meanings When example one terminates, it returns a number representing the success or failure of the program. These are the most common returns: ** NP ** Name No Meaning EOK 0 Success EFILNF -33 File Not Found EPTHNF -34 Path Not Found ENSMEM -39 Insufficient Memory ** /NP ** ** /boxout **