EASYEDIT from Sinclair User 39, Jun.1985 The painless way to programming We present a set of routines by David Wright to take the torment from Basic PROGRAMMING in Basic can be torture if you are trying to write a long program full of subroutines and complicated little twists. Perhaps there is not enough room between existing lines for that extra few instructions you need to get rid of an error. Perhaps you have forgotten where all the GOTO statements were for a line whose number you have changed. Such minor problems waste time and irritate the soul, leading to more errors through impatience and fatigue. David Wright's Easyedit utility takes the strain out of programming by providing eight extra commands which complement the Spectrum's editing facilities. It occupies a little under 4=K of RAM and is stored above RAMTOP, set at address 60701. Written in full machine code, it uses interrupt routines which enable each command to be accessed at any time during programming by pressing the appropriate keys. Each command starts by pressing #, and a full list is given in Table 1 for easy reference. Loading the code Type in the Basic program in list one, and make sure all the data is entered using capital letters. Save the program before you RUN it, and then RUN the program. As each line of data is read, a check is made, the checksum being the last two digits of the line, which is the remainder of the sum of the first twenty-two items divided by 256. When you finally receive the message "EASYEDIT now loaded" you can save the code with SAVE "EASYEDIT" CODE 60702,4664 and verify with VERIFY "EASYEDIT" CODE 60702,4664. If you have microdrives, type POKE 63132,4 beforehand to make sure there is always enough space to open a microdrive channel. You switch the program on with RANDOMIZE USR 60702. When LOADing the code back into the machine, enter CLEAR 60701 first, to protect the code above RAMTOP. What follows is a brief description of the various facilities offered by Easyedit. All the commands will prompt you for further input. The program also includes 31 new error codes to handle incorrect inputs to be found in Table 2. Renumber This renumbers the program or part of it in regular steps. The size of the step, or increment, should be from 1 to 255, and you then enter the first and last line numbers of the block to be renumbered, and the number for the new first line. By pressing ENTER instead of inputting a value the whole program is renumbered in steps of 10. The routine will handle GOSUB, GOTO, RESTORE, RUN, LIST and LLIST but not LINE. If you use something like GOSUB a*10, the routine will print out such expressions and tell you the new line number, but you must edit them in the normal way. Add/subtract This enables you to add or subtract a number from 1 to 9999 from every line number in a specified block of program. It is particularly useful if you have a program with many GOSUB expressions using variables instead of numbers, because the relative gaps between lines remain the same. In all other aspects, the routine works the same as the RENUMBER routine. Copy This copies one part of the program to another, enabling you to duplicate sections elsewhere in the program. Apart from the line numbers of the new block, the program is not changed. Delete This allows you to delete a block of program. It also asks you to confirm your choice, as the lines deleted cannot be recovered. Lines auto This generates new line numbers automatically when writing the program. To exit, press ENTER immediately after the new line number is generated. The routine will stop if it reaches a number where there are already existing program lines, to prevent you from inadvertently interlacing the new lines with the old. You cannot use the other routines in conjunction with LINES AUTO. Find An extremely powerful command. It allows you to input up to 16 characters, including keywords, graphics and tokens. All lines in which the chosen expression occurs will be printed on the screen with the relevant expression flashing. Use CAPS SHIFT and 9 to change the cursor mode when entering the expression, to get the appropriate characters or words. You could use the routine to find all occurrences of a particular GOSUB statement which you had assigned the wrong number. Or you could use it to check that you had not used a particular variable earlier in the program. Letters are printed in upper and lower case depending on whether CAPS LOCK was used before entering the routine. That does not matter as the routine does not distinguish between the two. Variables This tells you the values of system variables PROG, VARS, ELINE and RAMTOP if you know about such things. It also tells you the length of the Basic program, variables area, and the remaining free space. New The ordinary NEW command will deactivate the code routines, so Easyedit replaces it with a routine which deletes lines 1 to 9999 of any Basic program. The Easyedit routines were assembled with the aid of the Zeus Assembler from Crystal Computing. TABLE 1. AVAILABLE ROUTINES #R - Renumber #A - Add #S - Subtract #C - Copy #D - Delete #L - Lines auto #F - Find #V - Variables #X - switch off Easyedit TABLE 2. NEW ERROR CODES LINES AUTO 01 first line = existing program line number 02 next line number too large RENUMBER 03 too many digits input 04 more than three digits in increment 05 increment greater than 255 06 increment = 0 07 line number = 0 08 first line number greater than last line number 09 no Basic program found 10 actual line numbers coincide 11 increment too large for available space 12 new first line too small 13 new first line greater than actual line number after first line 14 new first line = actual line number after first line 15 too many lines in block to fit into gap even with increment = 1 ADD/SUBTRACT 16 no default for increment 17 add increment too large 18 subtract decrement too large FIND 19 more than 16 characters/tokens input DELETE 20 no default for first line number 21 first line number greater than last line number 22 no lines in block or single line number does not exist 23 first line number greater than actual last line in program COPY 24 no default for new first line 25 new first line coincides with actual program line numbers 26 new first line within block to be copied 27 new last line number in block greater than 9999 28 new last line number too large 29 insufficient space to copy block RUN ERROR 30 free space becoming too small 00 free space too small on calling routine Note that some of the renumber errors occur with the other routines. The circumstances under which those errors occur are the same as those described. -- Another Fine Product transcribed by: Jim Grimwood (jimg@globalnet.co.uk), Weardale, England --