This is the first of a series of tutorials designed to give TS2068 users some guidance on using the various TOOLKIT options. This article will focus on the renumbering functions: RENUMBERING, MOVING and COPYING BLOCKS of LINES. Do NOT use any of the renumber functions with programs that have machine code in REM lines.
BACKGROUND…
The program tstk.B1 with its code tstk.C1 is available from the club library and has also been included in several versions of the Omnibus disk. It originally appeared in the UK magazine Your Computer May 1985 page 91 written by D. Spagnol for the Spectrum computer. I subsequently adapted it to the TS2068 which included a redesign of the interrupt mode machine code section; then I adapted it back again to the Spectrum so that it would work with a Spectrum emulator.
Whenever you are going to use TOOLKIT, LOAD it, ensure both RANDOMIZE USR 59696 AND RANDOMIZE USR 60000 are used to activate it (the former activates the interrupt mode code; the latter brings up the TOOLKIT menu). BREAK back into BASIC using CAPS SHIFT 6 and put in the usual line 9999 RANDOMIZE USR 60000. This line is a MUST if you are going to use Renumber, Move, Copy, Machine Code to Data, UDGs to Data or Create a REM Line. It will stop new lines being created from overflowing into the variables area.
LINE RENUMBERING…
When any of the toolkit line renumbering routines are used, all affected GO TOs, GO SUBs, RESTOREs, LINEs, even LLISTs and RUNs are corrected throughout the entire listing (providing these all use real numbers and not variables or computed line numbers). Real numbers mean purely integer ones up to four figures in length.
If a computed line number is encountered, such as (GO TO 3190 +(CODE n$-96)*oj), TOOLKIT will not affect it. If it finds a variable,eg, GO SUB m1, it will not affect it either, but you must EDIT any line in which such variables are declared and alter the affected values. Make sure the changed variables get altered in the variables area. To do this, you would usually GO TO the program start line. You could of course EDIT the line again and DELETE the line number which will ensure all the changed variables in that line are placed in the variables area.
WARNING ABOUT SAVING…
As you use the various options, it is very wise to SAVE your work many times as you proceed. Something may go wrong. But a word of warning! Do not try to make a LARKEN AUTOSTART SAVE of your new listing unless the interrupts are NORMAL. Check toolkit option I; if the interrupts are diverted, press the X option on the menu to make them normal. Then go ahead with the AUTOSTART SAVE.
[M] MOVE LINES
Let’s investigate the MOVE option first. From the toolkit menu, select Move Lines (m) which prompts for start line number and 1st unaffected line number. Enter these and the destination line when prompted followed by the increment (usually 10 but not more than 100). The final prompt is Execute? and if all looks correct, press (Y). The task will be completed in seconds.
Subroutines (using GO SUB) should always be near the start of any listing (for maximum speed) so these are good candidates for MOVE. Choose a listing with such routines near the end of the listing or all over the place and try moving them up front.
[R] RENUMBER
Using RENUMBER is quite similar but it will ensure that line numbers do not overlap whereas MOVE will check the number of unused lines at the destination.
Make sure that there is enough memory left. It is possible to get an Out of Memory report if new line numbers after GO TOs are longer (ie, more digits) than the ones being replaced. If there is insufficient room to fit them in, the program will be corrupted usually beyond redemption. Keep SAVING as you go along, just in case! This warning applies to Move and Copy,too.
[C] COPY LINES
Copying blocks of lines is also very much the same. No GO TO destinations in lines outside the new block are affected but the new block is renumbered within itself. Any GO TOs pointing to an area before the original start of the copied block may be renumbered incorrectly. To prevent this happening, MOVE the block you want to copy to the head of the program, COPY it and MOVE it back to its original position.
ERROR REPORTS…
Error Message May occur in; (shown in INVERSE): Range Error Increment > 100 BCMNRTU. Numbers Reversed Start > Finish line ABCDJKLMPRS. Invalid Line Number Line > 9996 O> non-existent line. Zero Not Allowed self-evident CMNRTU. Lines Would Overlap Recheck what you are attempting R. No Room at Destination Not enough unused line numbers BCEM. Zero Block! No actual lines from start to end CD. Task Completed Done.
TS 2068 TOOLKIT A Alter Program N Autoline On B Bytes to DATA O Locate Token C Copy Lines P Compactor D Delete lines Q Display Memory E REM Create R Renumber F REM Delete S Search & List G UDG Designer T Trace on H Hex & Dec U UDGs to DATA I Information V List Variables J Merge Lines W Disable NEW K Upper Case X N/Q/T/W off L Lower Case Y Uncorrupt M Move Lines Z Line Sort PRESS A KEY FOLLOWED BY ENTER, or just ENTER anytime for menu