Notes on the Use of BASCOM #3 TRANSPORTABLE CLEAR SCREEN (C) Copyright 1985 Merlin R. Null (818) 762-1429 When you need the user to configure a program for clear screen in an interpreted MBASIC program it is easy to set up a string to be changed: 100 CLS$=CHR$(126)+CHR$(28) 'Change to your clear screen sequence 110 PRINT CLS$ And then just use PRINT CLS$ whenever you want to clear the screen. If you want your compiled program to be just as transportable, you must use something else. One possiblity is to use a small external data file: 100 OPEN "I",#1,"CLS.DAT" 110 WHILE NOT EOF(1) 120 LINE INPUT #1, A$ 130 CLS$=CLS$+CHR$(VAL(A$)) 140 WEND 150 CLOSE 160 PRINT CLS$ It would also be useful to add error checking for missing CLS.DAT: 600 IF ERR=53 AND ERL=100 THEN CLOSE ELSE 630 610 PRINT"CLS.DAT the clear screen data file not found, please create it." 620 RESUME 500 ' end 630 ON ERROR GOTO 0 The following code could be used to have the program install its own clear screen sequence: 600 IF ERR=53 AND ERL=100 THEN CLOSE ELSE 900 610 PRINT STRING$(18,10) 620 PRINT BL$;"CLS.DAT, the clear screen data file, not found." 630 PRINT"Please enter your clear screen sequence" 640 PRINT"one byte at a time in Decimal numbers. End your" 650 PRINT"entries with a to generate CLS.DAT" 660 PRINT 670 FOR I=1 TO 9 680 PRINT"Clear Screen character";I; 690 LINE INPUT C$ 700 IF C$="" AND I>1 THEN 790 710 IF C$="" THEN 680 720 IF LEN(C$)>3 THEN 680 730 FOR J=1 TO LEN(C$) 740 IF ASC(MID$(C$,J,1))<48 OR ASC(MID$(C$,J,1))>57 THEN PRINT BL$; "Whole decimal numbers only.":GOTO 680 750 NEXT J 760 IF I>1 THEN CLR$=CLR$+CHR$(13)+CHR$(10) 770 CLR$=CLR$+C$ 780 NEXT I 790 PRINT"Writing CLS.DAT"; 800 OPEN "O",#1,"CLS.DAT" 810 PRINT #1,CLR$ 820 CLOSE 830 RESUME 100 900 ON ERROR GOTO 0 This adds quite a bit of code to the program, so you might just want to add instructions to the documentation for your program on how to create CLS.DAT. For any terminal that uses ^Z for the clear screen, CLS.DAT would simply be: 26 Just two six return. For a most Hazeltine terminals it would be: 126 28 If you did not want to use the clear screen, a CLS.DAT that causes scrolling could be created: 10 10 10 10 10 10 etc. As many line feeds as you might want each time you would normally call for a clear screen. Another possiblity is to create CLS.DAT with a menu driven installation program. This way the user would only have to know his terminal or computer type to install a program. All of the above code can be used in an interpreted program as well as one compiled with BASCOM. There is a drawback to all of this. It does take a separate file for CLS.DAT. It may only hold a few bytes, but it will take up a whole block and a directory entry. If the user's system has little disk space or a limited number of directory entries, this can be a problem. Why bother with the clear screen? Often, a program is much faster if a full screen of text does not have to scroll off. The new text can be printed from the top down in the time it takes scrolling to move 1 or 2 lines. If you have gone to a lot of trouble to make your search or sort routine run as fast as possible, why waste it in screen update time? There are times when the clear screen is a pain in the neck. If you have ever had some important data vanish in an instant, you know what I mean. With many programs, the usual use is to call for a directory listing and then run the program. The initial prompt may require a filename from this directory listing. If you can't get a directory from inside your program or enter the second filename for the CP/M command line, then you force the user to remember that filename. 7-21-85 BASCOM AND MBASIC are trademarks of Microsoft