_settextposition

Description

Sets the text position.

#include <graph.h>

struct _rccoord __far _settextposition( short row, short column );

row, column New output start position  

Remarks

The _settextposition function sets the current text position to the display point (row, column). The _outtext and _outmem functions (and standard console I/O routines, such as printf) output text at that point. Note that _settextposition does not affect the text position for the _outgtext function; use the _moveto function instead.

The _rccoord structure, defined in GRAPH.H, contains the following elements:

Element Description

short row Row coordinate
short col Column coordinate

Return Value

The function returns the previous text position in an _rccoord structure, defined in GRAPH.H.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_gettextposition, _moveto, _outmem, _outtext, _settextwindow

Example

/* OUTTXT.C: This example illustrates text output functions:

* _gettextcolor _getbkcolor _gettextposition _outtext

* _settextcolor _setbkcolor _settextposition

*/

#include <conio.h>

#include <stdio.h>

#include <graph.h>

char buffer [80];

void main( void )

{

/* Save original foreground, background, and text position */

short blink, fgd, oldfgd;

long bgd, oldbgd;

struct _rccoord oldpos;

/* Save original foreground, background, and text position. */

oldfgd = _gettextcolor();

oldbgd = _getbkcolor();

oldpos = _gettextposition();

_clearscreen( _GCLEARSCREEN );

/* First time no blink, second time blinking. */

for( blink = 0; blink <= 16; blink += 16 )

{

/* Loop through 8 background colors. */

for( bgd = 0; bgd < 8; bgd++ )

{

_setbkcolor( bgd );

_settextposition( (short)bgd + ((blink / 16) * 9) + 3, 1 );

_settextcolor( 7 );

sprintf(buffer, "Back: %d Fore:", bgd );

_outtext( buffer );

/* Loop through 16 foreground colors. */

for( fgd = 0; fgd < 16; fgd++ )

{

_settextcolor( fgd + blink );

sprintf( buffer, " %2d ", fgd + blink );

_outtext( buffer );

}

}

}

_getch();

/* Restore original foreground, background, and text position. */

_settextcolor( oldfgd );

_setbkcolor( oldbgd );

_clearscreen( _GCLEARSCREEN );

_settextposition( oldpos.row, oldpos.col );

}