** 1 page regular / 878 words ** Basic BASIC! One of the computing laws of programming is Stockmayer's Theorem. It states "If it looks easy, it's tough - if it looks tough, it's damn near impossible". Stockmayer obviously didn't have HBASIC when he wrote his statement... Over the past few months I've shown you some of the basic functions of HBASIC. We can now continue with our PDO program adding much more features. This issue we'll concentrate on: ** UL ** * Adding the file selector for the print/view option. * Creating a Program Options dialog with the ability to specify a viewing program. * Checking for a command line and automatically going to the print command straight away. ** /UL ** To leave more space for an in-depth explanation the source code listing is only included on the Reader Disk this issue. The File Selector The file selector has been one of the nicest features of the Atari platform since the first TOS v1.0 machines sold in 1985 and it's one of the most useful programming tools and is fully accessible using HBASIC. The function comes in two versions, one for AES versions 1.62 or earlier (below TOS 1.4) and another one for later AES versions. Although the layout of the file selector has changed slightly over the years as extra refinements have been added the pre-AES call only differs in one way, it doesn't include a prompt "message" such as "Please select file to use" and so on. ** FSEL.GIF here ** I've included three extra subs/functions in the PDO source which are: SUB aes_version, SUB InitFileSelector and FUNCTION fileselector$. Both sub routines are used by the file selector function: ** UL ** * aes_version returns your AES version * InitFileSelector sets internal settings for the main file selector function. ** /UL ** The selector routine takes in one parameter, which is the message that is to be displayed. The routine first checks if the starting path has been defined (which is what InitFileSelector does) and then decides on which call to make, depending on your version of the AES. The variable fspath$ after the call is the last path of the program, which the extension of the search field as well. The loop is needed to get rid of this so the path and name (returned in fsname$) can be returned by the function. How can this be used? Well, if you find the ProcessUserMenus section and find "CASE view", you'll see I've used this function to get the user to select the file they wish to view. If the user clicks on Cancel, the function will return a null string, so this is also checked. Another feature we'll look at more closely next issue is the execution (running) of the external viewer (the "execute" statement). The same thing has also been done in the print file section. The Program Options form ** PROGOPTS.GIF here ** The code has been inserted as "CASE progopts". The first thing we do is to get the string for the external viewer in temp_1$ so that if the user clicks on Cancel, we can replace the stated address with the old temporary version. The program then goes into a loop, so that no matter what button the user presses, the form will never close until either the OK or Cancel button has been pressed. If the Cancel button is pressed, the file viewer disk address is changed back to what is was. If the Change viewer button was selected, another file selector is displayed - useful eh? When the routine actually finishes, there is a "global" (shared) variable named global_viewer$ which contains the name of the viewer which is used when the view file option is called on. Please note that the keyboard shortcut has also been added to SUB do_keybd. The Command line Remember in AC#12 we introduced the COMMAND$ command? Well, we're going to use it now - there's going to be automatic print option when double-clicking on a printable file (assuming it's had it's file type registered with the program). When the program first loads, the prinfile$ variable is set to the command line. If this is null the program will simply ignore it, otherwise the variable commandline is set to 1, and the print option is ran. In the print option, if the commandline variable is set 0 (which means a command line wasn't used) the program automatically asks the user for the file to be printed. In this case, if a file has been double-clicked on, the program is executed and the file printed straight away without having to select the file again. In the next few remaining issues, I shall be covering: ** UL ** * The execute routine, including the option for the VA protocol (below) * Using the VA protocol to call the external viewer. That is, in a multitasking system, if the program and the external viewer is being executed, both programs can communicate with each other. * The Registration validation (including exclusive version of the latest validation routines from ENCHANT) - including generating a real registration key using the check digit idea in AC#12. * Using ENCHANT. A full guide to each of the benefits of the using the system, including window dialogs, ST Guide help, BubbleGEM help, popup menus, check boxes etc. * Insights into the Virtual Language project. ** /UL ** Email: paul.jones31@virgin.net http://vzone.virgin.net/paul.jones31/