STRIP - Ampersand/backslash remover for BP2 V2 Kelvin Smith Financial Computer Systems, Inc. 1 Strawberry Hill Ct. Stamford, CT 06902 (203) 357-0504 This software is provided to the DEC community strictly on an as-is basis, at no charge and with no warranty. With the advent of BASIC-PLUS-2 version 2, backslashes and ampersands are no longer generally needed for multiple physical lines associated with a single line number (with some exceptions: multiple statements on a physical line need backslashes to separate them, and single statements extending over more than one line need ampersands to logically join them). However, DEC has provided no easy way of getting rid of the now-superfluous characters in older programs. As those who have tried to make the changes have no doubt found, it is not as easy as it might seem at first glance. Globally deleting all ampersands requires putting them back in by hand for most MAP, OPEN, and multi-line PRINT statements; globally deleting all amperands or all backslashes also leaves the possibility of taking one out of the middle of a PRINT statement (an error which may be very difficult to detect in normal debugging). In order to avoid all these problems, I have devised the TECO macro which follows this article. STRIP has been used on dozens of programs with no ill effects--the right and only the right ampersands and backslashes are removed. Restrictions: (1) BP2 version 1.6 allowed lines of the form: 100 ! Comment here & \ NORMAL STATEMENT (PRINT, LET, etc.) Note the superfluous backslash. This backslash remains after a program is sent through STRIP, and BP2 version 2 will signal an error. (2) STRIP will leave an ampersand after any THEN or ELSE statement which is at the end of a line. Ampersands are not necessary either before a THEN/ELSE at the beginning of a line or after a THEN/ELSE at the end of a line, but they do not cause any problem either. (Fixing this restriction would require significant additional coding to skip over possible comments at the end of the line; since my own programming style is to always put THEN and ELSE at the beginning of the line, I wasn't willing to take the STRIP - Ampersand/backslash remover for BP2 V2 Page 2 time.) (3) If a line starts with an exclamation point to introduce a comment, all of the line is assumed to be a comment, although a second exclamation point can terminate the comment and valid code can follow. This is bad programming practice anyway, because it makes the code difficult to find; again, since I don't write programs that way, I have not bothered to make STRIP handle it. (4) The only backslashes removed are at the beginning of a line. If your program's backslashes are at the end of the line, you will need to reposition them. The BSLASH TECO macro, also included in this submission, will make those changes. Another very important warning: after using STRIP, do not use the "/B2" or the related "/n" (where n is some number) switch for TECO editing. If you do, TECO will put ampersands back in at the end of each line; since STRIP depends on the backslashes to tell it when to delete an ampersand and when to leave it, STRIPping such a file will be useless. Operating procedures: STRIP expects the line continuation to be done in the following form: regular information, one space or tab, ampersand, carriage return. If your program is not in this format, you should prepare it by entering TECO, doing an EBfilnam/B2, and exiting (or alternatively using the CCL command TECO filnam/B2 and immediately exiting). Once your program is in this format, enter TECO again, ER-EW or EB your program without the "/B2" _______ or any similar switch, and execute STRIP with the EI command (EI STRIP)--you must be on the first TECO page of the program. STRIP will perform the necessary operations on the entire program, leaving you on the last TECO page when finished. For large programs, STRIP may take up to a minute or more to finish its work. In order to make sure that there are no typos in the printing of the macro here, or your typing it in, try it on a short program first to be sure that it really isn't in an infinite loop. You may, however, abort the operation at any time with CTRL/C and then restart the operation with no problems. There is one remaining incompatibility between BP2 V1.6 and BP2 V2: the former allows an exclamation point (indicating a comment) in the first column of a line. With the latter, this is no longer legal (after the ampersands are taken out)--the first column may only contain a digit for a line number or a space or tab. This seems to have been done because of the pseudo-immediate mode option in BP2 V2--some way was necessary to distinguish a statement to be STRIP - Ampersand/backslash remover for BP2 V2 Page 3 added to the program from one to be executed immediately. In keeping with this, STRIP places a space immediately preceding any exclamation points which begin a physical line.