SUB SaveRestScrn (ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) ' +----------------------------------------------------------------------+ ' | SUB SaveRestScrn | ' +----------------------------------------------------------------------+ ' | Not counting REM (') lines, SUB SaveRestScrn has 34 lines. | ' +----------------------------------------------------------------------+ ' | SUB written by Don Smith on 03/25/02 - Public Domain FreeWare. | ' | No need to name Don as the author. EMail: smithdonb@earthlink.net | ' | SUB SaveRestScrn will save a designated portion of the screen and | ' | later restore the same. | ' +----------------------------------------------------------------------+ ' +----------------------------------------------------------------------+ ' | PROGRAM SETS NUMBERS 1 AND 2 -> | ' +------------------+---------------------------------------------------+ ' | (1) ReadLine$() | Program self reads data at each Row and Column | ' +------------------+---------------------------------------------------+ ' | (2) ReadColr%() | Program self reads color at each Row and Column | ' +------------------+---------------------------------------------------+ ' | THE PROGRAMMER MUST SET NUMBERS 3 TO 9 -> | ' +----------------------------------------------------------------------+ ' | (Note: The "SR" below means "Save" Or "Restore") | ' +------------------+---------------------------------------------------+ ' | (3) SR.UL.Row% | Screen to save or restore at upper left row. | ' | (4) SR.UL.Col% | Screen to save or restore at upper left column. | ' | (5) SR.LR.Row% | Screen to save or restore at lower right row. | ' | (6) SR.LR.Col% | Screen to save or restore at lower right column | ' | +---------------------------------------------------+ ' | | SPECIAL CAUTION: | ' | | --------------- | ' | | When you call the SUB to restore the underlying | ' | | screen, use MUST use the same row and column | ' | | numbers as you used when you first called the | ' | | SUB to save the screen. | ' +------------------+---------------------------------------------------+ ' | (7) SaveOrRest% | SaveOrRest% = 1 (1 means save the screen) | ' | | SaveOrRest% = 2 (2 means restore the screen) | ' +------------------+----------+----------------------------------------+ ' | (8) REDIM ReadLine$(25) | The REDIM for ReadLine$ and ReadColr% | ' | REDIM ReadColr%(25, 80) | must be placed in the main module | ' | | before calling the SUB. The 25 and 80 | ' | | reflects a screen of 25 lines and 80 | ' | | columns. You may use smaller amounts | ' | | of memory if you do not need all 25 | ' | | lines and 80 columns. | ' +-----------------------------+----------------------------------------+ ' | (9) ERASE ReadLine$ | Reclaim memory after calling the SUB | ' | ERASE ReadColr% | to restore the screen. Use REDIM and | ' | | ERASE in main module please! | ' +-----------------------------+----------------------------------------+ ' | +-----------------------------------------------------+ | ' | | Example of how to use SaveRestScrn in main module. | | ' | +-----------------------------------------------------+ | ' | | ' | I have found that dimensioning the screen as below with 25 rows | ' | and 80 columns (the entire screen, in other words), works quite | ' | well because of the speed of SUB SaveRestScrn. In this way, all | ' | that is required to save the entire screen is to write the code, | ' | "GOSUB save.screen" and to restore, GOSUB "restore.screen". | ' | | ' | save.screen: | ' | REDIM ReadLine$(25) | ' | REDIM ReadColr%(25, 80) | ' | SR.UL.Row% = 1 | ' | SR.UL.Col% = 1 | ' | SR.LR.Row% = 25 | ' | SR.LR.Col% = 80 +---------------------------------------+ ' | SaveOrRest% = 1 | ' | CALL SaveRestScrn(ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) | ' | RETURN | ' | +---------------------------------------+ ' | restore.screen: | ' | SR.UL.Row% = 1 | ' | SR.UL.Col% = 1 | ' | SR.LR.Row% = 25 | ' | SR.LR.Col% = 80 +---------------------------------------+ ' | SaveOrRest% = 2 | ' | CALL SaveRestScrn(ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) | ' | ERASE ReadLine$: ERASE ReadColr% | ' | RETURN +---------------------------------------+ ' | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ' | -OR- | ' | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ' | If you prefer to write less code, put this in the main module: | ' | | ' | save.screen: | ' | REDIM ReadLine$(25): REDIM ReadColr%(25, 80) | ' | CALL SaveRestScrn(ReadLine$(), ReadColr%(), 1, 1, 25, 80, 1) | ' | RETURN | ' | | ' | restore.screen: | ' | CALL SaveRestScrn(ReadLine$(), ReadColr%(), 1, 1, 25, 80, 2) | ' | ERASE ReadLine$: ERASE ReadColr% | ' | RETURN | ' +----------------------------------------------------------------------+ ' | SPECIAL NOTE: | ' +----------------------------------------------------------------------+ ' | NOTE: If there is an additional screen to save/restore, at the | ' | same time that another screen is in the SAVE mode, that is not | ' | a problem - just use another name. | ' | | ' | +-------------------------------------------------+ | ' | | EXAMPLE using DaBigScreen$ instead of ReadLine$:| | ' | +-------------------------------------------------+ | ' | | ' | Example to SAVE: | ' | --------------- | ' | save.screen: | ' | REDIM DaBigScreen$(25): REDIM DaBigColor%(25, 80) | ' | CALL SaveRestScrn(DaBigScreen$(), DaBigColor%(), 1, 1, 25, 80, 1)| ' | RETURN | ' | | ' | Example to RESTORE: | ' | ------------------ | ' | restore.screen: | ' | CALL SaveRestScrn(DaBigScreen$(), DaBigColor%(), 1, 1, 25, 80, 2)| ' | ERASE DaBigScreen$: ERASE DaBigColor% | ' | RETURN | ' +----------------------------------------------------------------------+ IF SR.LR.Col% > 80 THEN SR.LR.Col% = 80 END IF IF SR.LR.Row% > 25 THEN SR.LR.Row% = 25 END IF IF SaveOrRest% = 1 THEN GOSUB save.scrn ELSEIF SaveOrRest% = 2 THEN GOSUB restore.scrn END IF EXIT SUB save.scrn: FOR ViewIt% = SR.UL.Row% TO SR.LR.Row% FOR Horizon% = SR.UL.Col% TO SR.LR.Col% ReadLine$(ViewIt%) = ReadLine$(ViewIt%) + CHR$(SCREEN(ViewIt%, Horizon%)) ReadColr%(ViewIt%, Horizon%) = SCREEN(ViewIt%, Horizon%, 1) NEXT NEXT RETURN restore.scrn: FOR FindRow% = SR.UL.Row% TO SR.LR.Row% FOR ScrnCol% = SR.UL.Col% TO SR.LR.Col% LOCATE FindRow%, ScrnCol%, 0 OneColr% = ReadColr%(FindRow%, ScrnCol%) FGScrnColr% = OneColr% MOD 16 BGScrnColr% = OneColr% \ 16 COLOR FGScrnColr%, BGScrnColr% PRINT MID$(ReadLine$(FindRow%), ScrnCol% - (SR.UL.Col% - 1)); NEXT NEXT RETURN END SUB