** 1 page regular / 570 words ** Basic BASIC There are three types of errors when creating programs: syntax, run time and logical (human) errors. Guess which is the most common? Now read on with Paul Jones... If you've ever double-clicked on a text file and wondered how your installed text editor knows which program to display here's your chance to find out. We'll be looking at command lines - what they are, how they work and what they can do for you. This involves some string manipulation (Ed: as covered in AC11). Applications can be installed under TOS using the Install Application option. This dialog includes a file extension field which can be used to specify a file extension. Double-clicking on any file whose file extension has been assigned to a specific application results in TOS automatically launching the appropriate application and passing the filename to it via a command line. Using a command line in HiSoft BASIC is straightforward. Start HBASIC then enter the following code: ** HBAC1201.GIF here ** The COMMAND$ function gets the command line and, in this case, puts the contents into A$. The OPEN command was explained briefly in AC9. This little routine opens the file OUTPUT.CMD to which we can can write the command line before closing it again. Compile the program to disk and exit HBASIC. Now, from the desktop find the program, highlight it (single click on icon) and configure it for the TXT file extension and, if your TOS version supports it, set the full path option. Click on OK/Install then double-click on a TXT file. If everything went according to plan, the command line program should have been loaded and executed automatically and in the same directory as the command line program you should find the file OUTPUT.CMD. If you view this file you should find the location of the text file you clicked on listed! Using this technique we could configure PDO to spring to life ready to print any text files the user may click on or we could send "arguments" to programs. For example, the excellent POV raytracing program accepts command line arguments which it decodes to determine various options. For example, the output size of the image "-w480" sets the width to 480 pixels and "-h640" sets the height to 640 pixels - POV includes many other command line arguments which provide comprehensive control over the program options and output image. Arguments are not so easy to extract from command lines but I've created a routine, which is included on the Reader Disk, to do just this. The syntax of the function is: ** On Reader Disk logo here ** argument$=get_cmd$(command_line$,argument_number) This routine works fine but doesn't support long filenames which include spaces because this function regards a space as the beginning of an argument. This may also be true for get_num (command_line$) which returns how many arguments there are. Here's an example using the routines: ** HBAC1202.GIF here ** Fights, scraps and arguments Although this isn't especially applicable to PDO, it may well be useful for your own projects. Once we have an argument (-q20 for example) how can we turn this into something useful in the program? Assuming each of your main arguments were two characters long (the minus symbol then a letter for the code) you could proceed as follows (assuming a$ contains the argument and option w always has a trailing numeric parameter): ** HBAC1203.GIF here ** If the -w argument is used, v would contain the value that follows it. For example, if -w203 was the parameter, a should contain 203. ** boxout ** Contacts: Email: Paul.jones31@virgin.net http://vzone.virgin.net/paul.jones31/ ** /boxout **