C Language Development Kit/Functions/SaveDisplay

From OptiWiki

Jump to: navigation, search
Description Saves the pixels of a screen display into a file. This function is useful when implementing

help screens after which the original screen must be restored.

Syntax
int savedisplay(char * filename);
Arguments
char * filename
Points to a string containing the name of a file into which a screen display will be stored.
Returns
OK savedisplay() opened the file and saved the contents of the screen display.
ERROR savedisplay() could not open or write the file.
Remarks When the file cannot be opened or written to an error will be returned. The saved screen

can later be restored with the function loaddisplay(). The settings of the font, cursor and contrast from the orginal screen will also be saved.

Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    int turn;
 
    printf("\fThis is screen\nnumber ONE.");
    savedisplay("screen1.dat");
    delay( 100 );
    printf("\fThis is screen\nnumber TWO.");
    savedisplay("screen2.dat");
 
    turn = 1;
    for(;;)
    {
        resetkey();
        while( !kbhit())
            idle();
        if( turn == 1)
        {
            loaddisplay("screen1.dat");
            turn = 2;
        }
        else
        {
            loaddisplay("screen2.dat");
            turn = 1;
        }
    }
}


Views
Personal tools