Previous Topic Next topic Print topic


CBL_SCR_SAVE

Saves away an area of the screen (text and attributes) for subsequent restoration.

Note: This routine is supported for native COBOL only.

Syntax:

call "CBL_SCR_SAVE" using by value       flags
                                         top-line
                                         bottom-line
                               returning handle.

Parameters:

  Using call prototype (see Key) Picture
flags cblt-x4-comp5. pic x(4) comp-5.
top-line cblt-x4-comp5. pic x(4) comp-5.
bottom-line cblt-x4-comp5. pic x(4) comp-5.
handle cblt-pointer. usage pointer.

On Entry:

flags Currently, this must always be zero.
top-line The line nearest the top of the screen of the area to be saved. Line 1 is the top line.
bottom-line The line nearest the bottom of the screen of the area to be saved. Line 1 is the top line.

The area between the top-line and bottom-line inclusive is saved. Therefore, if top-line and bottom-line are equivalent, a single line of the screen is saved.

Note that specifying zero as a top-line or bottom-line means that parameter will be considered to be the last line on the screen. This saves you from having to know the size of the screen if, for instance, you wished to save the whole screen.

The logical value of top-line must be equal or less than the logical value of bottom-line.

On Exit:

handle Contains either a "save handle", which can be subsequently passed to the CBL_SCR_RESTORE call-by-name routine, or the value NULL, meaning that the save operation could not be performed (because of bad parameters, or possibly lack of memory).

Comments:

Because the three parameters are passed BY VALUE, any or all of them may be specified with numeric literals. For example, "BY VALUE 12 SIZE 4".

CBL_SCR_SAVE has advantages over reading areas of the screen directly:

  • There is no need to have wasteful buffer space allocated in the working-storage section of your program.
  • Using any single-byte attribute method to write the screen (for example CBL_READ_SCR_ATTRS) requires indirection through the Generic Attributes system and thus a best-match guess has to be made for attributes not in the current palette.
  • This call is very fast.

If handle is not subsequently passed to the CBL_SCR_RESTORE routine, any core memory that may have been allocated to save the screen information in will be lost. Repeated failure to call CBL_SCR_RESTORE with handles returned will therefore result in a memory leak.

It is invalid to pass handle to any routine other than CBL_SCR_RESTORE.

Examples:

To save the screen in its entirety, whatever its size:

call "CBL_SCR_SAVE" using by value 0 size 4 
                                   1 size 4 
                                   0 size 4 
                         returning handle.

To save just the last line of the screen:

call "CBL_SCR_SAVE" using by value 0 size 4
                                   0 size 4
                                   0 size 4
                         returning handle.

To save the top three lines of the screen:

call "CBL_SCR_SAVE" using by value 0 size 4
                                   1 size 4
                                   3 size 4
                         returning handle.
Previous Topic Next topic Print topic