PROGRAMMERS DREAM (C) Work Force 1982 Programmers Dream (R.D) is an advanced TOOLKIT adding extra features to the standard Spectrum. Written entirely in M/CODE it is position independent allowing relocation as required and will not become redundant if memory is upgraded. The following features are contained within the package. (1) RENUMBER (2) BLOCK MOVE (RENUMBER) (3) BLOCK OR LINE ERASE (4) CHANGE STRINGS (5) DUMP (VARIABLE NAMES AND VALUES) (6) DISPLAY PROGRAM AND VARIABLES SIZE. The entire program consists of 1450 BYTES which is the result of its author's (DR ROBERT RAYMENT) efforts to produce good compact coding with a minimal memory overhead. Prior to loading P.D.RAMTOP must be reset to preserve a safe area for the CODE. For simplicity we will reset RAMTOP to 62000 and load the program at 63000. This relates to a 48k Spectrum. 29000 and 30000 would do for a 16k Spectrum although any number can be used providing RAMTOP is less than the loading point and there is room for the CODE and your program. TYPE CLEAR 62000 (or your preference) this sets RAMTOP. Follow this by LOAD "stk" CODE 63000, 1450 ."stk" Being the program name, 63000 the position to load and 1450 the length of the CODE to be loaded. When the 0 ok, 0:1 message appears P.D is loaded and ready. SYNTAX P.D requires one single line of BASIC control its facilities. This takes the form of 9999 REM followed by the instructions each of which is separated by a space. The SYNTAX of each of these instructions will be shown in the examples. RENUMBER Renumber has a default status which consists of an automatic renumber of the whole program; the first line becomes 10 and the remainder progresses in steps of 10 to the end of the program. This status is invoked by a blank REM . I.E. 9999 REM (blank). To use Renumber to its fullest extent the following parameters can be specified. N.B. The following terms are used throughout the examples. ST = START NUMBER ....... NS = NEW START NUMBER ... NI = NEW INTERVAL ....... SP = STOP LINE NUMBER ... Try typing in the following .... 1 RUN 2 GO TO 6 3 LIST 4 RETURN 5 REM 6 GO SUB 3 9999 REM Now you are ready to invoke the Renumber routine. As this is written in M/CODE it is called by the USR function. Whilst RANDOMIZE USR nnnnn or LET £ = USR nnnnn can be used PRINT USR nnnnn has the extra facility of displaying a useful number on the screen. So to invoke Renumber enter .... PRINT USR 63000 63000 being the location of the program as defined when loading the program into memory. On completion 9999 will be displayed on screen and the program will be renumbered in steps of 10. The following are more specific instructions allowable... 9999 REM ST = Renumber from the (ST) number, starting at 10 in steps of 10 up to line 9999. I.E. NS is the default value, if this doesn't fit then a block move (see later) will be attempted. 9999 REM ST NS = Renumber from the (ST) number given starting at the (NS) number in steps of 10 up to line 9999. I.E. NI=10 as default value. 9999 REM ST NS NI =Renumber from the (ST) number given starting at the (NS) number in steps as specified in (NI) up to line 9999. I.E. SP=9999 as default value. 9999 REM ST NS NI SP = Renumber from the (ST) number given, starting at the (NS) number in steps as specified in (NI) up to (and including) the (SP) number as specified. In case you are not sure take the result of your first try and renumber it from 100 in steps of 2. To do this use the following 9999 REM 10 100 2 60 Start at 10, New start 100, In steps of 2, Stop when you have renumbered line 60. PRINT USR 63000 and when the screen shows 9999 you will have 6 lines of program renumbered from 100 to 110 in steps of 2, EASY EH!. The rules for Renumber are as follows. If you specify a START number P.D. will take the next up if it does not exist. The same applies to a non-existent stop line number. If in place renumbering cannot be achieved P.D. will (if possible) move the lines involved, (SEE BLOCK MOVE). Non existant line numbers are resolved if they are included in a renumber pass. Error messages are supplied if you attempt the impossible so don't be afraid to experiment. P.D. will renumber all GOTO, GOSUB, LLIST, RUN, LIST, RESTORE which have branch addresses in the affected area. BLOCK MOVE Using the capabilities of the last section fully, complete chunks of program can be moved around at will, which is particularly useful for reorganising subroutines. The best advice I can give is to watch your target area as P.D. won't allow you to direct code to an already occupied area. If you think about it moving blocks is easy, the (ST) is the beginning of block (source). The (NS) becomes the Target and the (SP) the end of the block to be moved. The (NI) now takes on a new importance because it renumbers the lines as they are inserted into the target area. No problem if there is plenty of room but you will be rewarded with an error message if you try to squeeze a quart into a pint pot. To summarise ... 9999 REM SOURCE TARGET INTERVAL END Moves a block of program with a length from SOURCE to END and will place it starting at TARGET with a renumber in steps of INTERVAL, GOT THAT?. ERASE You shouldn't find this too difficult. The Syntax is very much the same with the exception of the ERASE instruction "e" (LOWER CASE E). ST = the start line (include) and SP = the stop line (included). So .... 9999 REM e 10 20 Will ERASE lines 10 to 20 (inclusive). If either ST or SP do not exist the next up are taken by P.D. 9999 REM e produces INVALID ARGUMENT. CHANGE STRING This can be used to change either every occurance of a string or selective occurrences by picking program lines. The Syntax is as follows. The CHANGE instruction is "c" (LOWER CASE C). The (ST) can be specified if selective change is required, as can the (SP). For a complete string change the following will suffice.... 9999 REM c STRING 1 STRING 2 Other acceptable instructions are as follows ... 9999 REM C ST STRING 1 STRING 2 Will change strings from the (ST) given to the end of the program. 9999 REM c ST SP STRING1 STRING 2 Will only change strings between (ST) and the (SP) as defined. The RULES are that ST & SP are included, the separator is a space therefore there must be no spaces in the first string, neither must it contain characters with codes less than 32. In the second string any codes (INCLUDING CONTROL CHARACTERS) can be used. To place commands in the REM THEN may be used and deleted when no longer required. If you feel inclined you can have some fun with this as you can change the contents of a string, a string name, some commands, functions and operators at will. You can change numbers but you may find that your program tells LIES !!!! If you use the PRINT URS nnnn in a program line, as discussed later, you will have a fast editor for those long lines of program when you wish to change variables or values. DUMP Dump (what a great name) dumps variable names and values on the screen as required. This can be used within a FOR NEXT LOOP if required. The instruction is again held in the 9999 REM and its Syntax is as follows. The DUMP instruction is "d" (LOWER CASE D) and the only other entries required are the number of subscripts to print from numeric or string arrays. This takes the form of... 9999 REM d N1 N2 N1 is the number of subscripts to print from a NUMERIC ARRAY and N2 the number from a STRING ARRAY. All the program variables will be DUMPED and therefore if you are uninterested in ARRAYS then specify 9999 REM d 1 1 and the display will be minimal. If you want to default then the option is 9999 REM d (blank) (blank) and this will display the first 10 subscripts of each numeric array and up to 9999 values of string arrays. The whole of simple string variables are also printed. To use within a LOOP the 9999 REM needs to be set as required and the PRINT USR nnnn program line should be imbedded within the loop, this will dump the variables each time it is called within the loop. Poking (SCR CT) 23692,255 will suppress the scroll if you are happy to read the screen at P.D.'s speed. PROGRAM AND VARIABLES SIZE This will print either the program size or the program plus variables size depending on how the inquiry is approached. The instruction is "p" (LOWER CASE P) and there are no additions to this. I.E.... 9999 REM p If the program is cleared (CLEAR) and then PRINT USR nnnnn is called the resultant output is the program length only. If the program is then RUN and the same call is made the variables and the program length will be returned. SUMMARY The easiest method for frequent usage is to set up a 998 PRINT USR nnnnn followed by the 9999 REM and the instructions required. This can also be supplemented by LIST in order that the alterations can be checked on completion. Using the LIST addition will FLAG the last altered GOSUB with a flashing cursor when listed. The output from PRINT USR nnnn varies depending on the action, RENUMBER next unaffected line, BLOCK MOVE number of BYTES moved. CHANGE STRING next unlooked at line, DUMP 128 the variables area terminator and in ERASE next unaffected line. A word about ERROR MESSAGES. If P.D. can't understand the 9999 REM an INVALID ARGUMENT message will be put out. If however P.D. reads the REM and decides it doesn't like the instructions PARAMETER ERROR will be put out. If you receive either message look carefully at the 9999 REM. Sometimes you may receive an OUT OF MEMORY ERROR message, usually when trying to move a large block in memory. Try moving smaller blocks or single lines if memory is really tight. DR ROBERT has coded the program to disregard most illegal structures. You will have to watch out for the real boobs like deleting when you wanted to renumber but once you've done that a few times you will be more aware of the instructions you have in the REM before calling P.D. We hope you use P.D. regularly and that we have got you off to a good start. HAPPY PROGRAMING WRITING FOR WORK FORCE By now you will have an idea of how we feel about quality, documentation and the end user. We are intending to continue this support and increase our product range for the Spectrum. At the time of writing we have three first class utilities and two all M/CODE arcade games available when many Spectrums are yet undelivered. To continue this momentum we require further freelance writers to join with us to create the best range of programs available. We take care of documentation, production, promotion and take all the commercial risk. You are free to create quality programs and receive royalties each month. These royalties allow Work Force to promote effectively and ensure that around 50% of the profit is directed to the author. We welcome programs for all sectors of the market and for all ages. We are not pedantic regarding submissions, the minimum requirement being a cassette and a scribbled note if the program requires it. The work must be your own and we would be looking for worldwide distribution. If you are interested then give DEREK a ring on (0582) 454456 any evening or drop us a line.