Sinclair’s line editor for BASIC programs leaves a lot to be desired. (This is a common failing among micros – even the MAC isn’t much better.) One feature that most word processors offer is block moves, where a sentence or paragraph can be transferred to a new position within the document.
When working on a long program, there may be times where you would like to move a subroutine to the front to improve its speed, or move a little-used routine to the back to improve the general flow of the program. Neither Sinclair nor any other micro allows you to do this, but you can use the 2068’s DELETE and MERGE to allow block moves of program lines within a program.
There is one item that is needed before blocks can be easily moved; that is a renumber utility (other computers do offer this). For the 2068, the routine below will do the job.
The routine requests three numbers; “Start”&”End” represent the current line numbers to be changed, and “Start renumber” is the new value to begin renumbering from. N holds the new line value to be inserted, and line 9100 controls the increment size – now set at 10.
The routine is fairly bombproof – just remember to change GOTOs and GOSUBs to the new values. Doing an LLIST before renumbering can be an aid to correctly changing the GOTOs. If you accidentally end up with line numbers out of order, renumber the entire program before attempting to RUN
9000>REM ********** Renumber and
Save **************************
9010 INPUT "Start ";start
9020 INPUT "End ";end
9030 IF end>=9000 THEN LET end=9
000
9040 INPUT "Start renumber using
";n
9050 LET x=PEEK 23635+256*PEEK 23
636
9060 IF PEEK x*256+PEEK (x+1)<sta
rt THEN GO TO 9110
9070 IF PEEK x*256+PEEK (x+1)>=en
d THEN STOP
9080 POKE x,INT (n/256)
9090 POKE x+1,n-PEEK x*256
9100 LET n=n+10
9110 LET x=x+4+PEEK (x+2)+PEEK (x
+3)
9120 GO TO 9060
Block Moving
Once the renumber utility is in, there are four steps to transferring a block of code.
1. Find a block of numbers big enough to hold the subroutine to be moved. If necessary, the renumber utility can be used to open up a group of lines at the desired value.
2. SAVE off the complete program. If you’re chicken, like me, VERIFY the SAVE.
3. DELETE all line numbers not in the section to be transferred, or the renumbering routine. DELETE 1,2000 will delete lines 1 through 2000; If you want to keep 2000, use DELETE 1,1999. It will take two DELETEs; one for the numbers below your block, and one for the numbers between your block and 9000
4. MERGE the original program together with the newly numbered lines. MERGE preserves all lines of program and variables; however, if a line has the same number or a variable has the same name in the memory and on the tape, the tape’s version is substituted.
That’s all there is to it. It’s much faster than EDITing each line and changing each line number. Happy coding!
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.