SB BBC @ GBR Oldie hints/tips #121-124 Hints and tips from the archives of Wakefield BBC Micro User Group... 121. Merging BASIC programs ~~~~~~~~~~~~~~~~~~~~~~ There is no single command which will merge a program on tape or disc with one in memory. This is a shame, as it is useful to be able to tack Procedures from a 'library' onto new programs being written. Some utility ROMs such as Beebug Toolkit incorporate a merge facility, but there are ways round the problem. Method 1 is considered 'dirty' by the purists, but is very effective. Assuming that the main program is in memory, and that the Procedure or routine which you wish to add is on tape or disc, under the filename "fname". Type PRINT~TOP-2 , and note the 3 or 4 digit Hex number which is printed; I shall represent this as 'nnnn'. Now type *LOAD fname nnnn , followed by OLD , (vital), and the merge is complete. This method adds the Procedure onto the end of the program, regardless of the line numbers. For example, your program may use lines 100-2500, and your Procedure may appear as lines 1000-1050 after line 2500. This looks weird, but can be cured simply by RENUMBERing the program. This oddity is actually very useful, because you don't have to worry about the line numbers in the Procedure clashing with those in the main program but if you don't want to renumber the program, then try method 2. Method 2 is more tedious, but may be better on some occasions. First, load your Procedure or routine into memory. It is a good idea to renumber it at this stage, so that the line numbers will not clash with those in the main program. Now save it as a straight ASCII file, ie character-by-character rather than in compressed BASIC keyword token form. TYPE *SPOOL fname followed by LIST . When the listing stops, type *SPOOL on its own to close the file. If you are saving only one part of a longer program, then type LIST 1000,1050 etc instead of just LIST . Now load your main program into memory and add the Procedure with *EXEC name. You will actually see the lines being added on the screen, together with a couple of "Syntax error" messages, which you may ignore. The lines are being added as if typed very quickly on the keyboard, so any common line numbers will be overwritten and the new lines will appear in the correct order. There is no need to subsequently renumber the program, unless you particularly want to. You can keep a library of these Procedures already in ASCII format, so you don't need to use *SPOOL every time. You can then just *EXEC them into your programs as required, which is fairly convenient. You could store them, each with a different set of lines numbers, but this would be hard to keep track of. Alternatively, store them all with high line numbers, say 30000 upwards and every time you add one to a program, renumber the program so that the highest line number becomes relatively low. In that case, you may find method-1 more suitable. 122. REM alternative ~~~~~~~~~~~~~~~ The characters "*|" have the same effect as a REM statement, and can conveniently be incorporated in *EXEC files etc. Eg. *| This is my !BOOT file 123. VDU code reminder ~~~~~~~~~~~~~~~~~ You may not be aware that VDU codes may be used in place of some PRINT statements. For example, the term VDU(n) is directly equivalent to the term PRINT CHR$(n); . Note that the brackets are optional in both cases and that there is a semicolon after the latter term. Also, VDU31,x,y is directly equivalent to PRINT TAB(x,y); Thus, the two statements below are directly equivalent, but the second one is shorter and tidier. This will not necessarily save much memory space as the second line is only one byte shorter than the first but even if you don't save any memory space, a shorter listing is an advantage in itself. 10 PRINTTAB(10,12)CHR$136;CHR$131;:INPUT"Name ? "N$ 10 VDU31,10,12,136,131:INPUT"Name ? "N$ 124. VDU oddities ~~~~~~~~~~~~ VDU19, which chooses foreground and background colours from the palette, is equivalent to pressing . I shall represent it by |S, since this is how you would store it on a red key. To select a foreground colour of Green in Mode 0, you could use VDU19,1,2,0,0,0 or press |S followed by the keys 1 2 0 0 0 in turn. To send a zero byte in this way properly involves pressing |@. By pressing the 0 key directly, you are actually sending ASCII code 48. Thus you have sent the equivalent of VDU19,49,50,48,48,48 and in fact it does work perfectly as a VDU command; try it and see! You can do it 'properly' by pressing |S |A |B |@ |@ |@ I'm not quite sure what practical use you can put this new-found knowledge to, but there it is for what it's worth! 73 Rick G4BLT @ GB7WRG