RAD Studio
ContentsIndex
PreviousUpNext
gettext

Header File 

conio.h  

Category 

Console I/O Routines 

Prototype 

int gettext(int left, int top, int right, int bottom, void *destin); 

Description 

Copies text from text mode screen to memory. 

gettext stores the contents of an onscreen text rectangle defined by left, top, right, and bottom into the area of memory pointed to by destin. 

All coordinates are absolute screen coordinates not window-relative. The upper left corner is (1,1). gettext reads the contents of the rectangle into memory sequentially from left to right and top to bottom. 

Each position onscreen takes 2 bytes of memory: The first byte is the character in the cell and the second is the cell's video attribute. The space required for a rectangle w columns wide by h rows high is defined as  

bytes = (h rows) x (w columns) x 2

Note: Do not use this function in Win32 GUI applications.
Return Value 

gettext returns 1 if the operation succeeds. 

On error, it returns 0 (for example, if it fails because you gave coordinates outside the range of the current screen mode). 

Example  

#include <conio.h>
 
char buffer[4096];
int main(void)
{
   int i;
   clrscr();
   for (i = 0; i <= 20; i++)
      cprintf("Line #%d\r\n", i);
   gettext(1, 1, 80, 25, buffer);
   gotoxy(1, 25);
   cprintf("Press any key to clear screen...");
   getch();
   clrscr();
   gotoxy(1, 25);
   cprintf("Press any key to restore screen...");
   getch();
   puttext(1, 1, 80, 25, buffer);
   gotoxy(1, 25);
   cprintf("Press any key to quit...");
   getch();
   return 0;
}

Portability

POSIX 
Win32 
ANSI C 
ANSI C++ 
 
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!